3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $us_states = array( 'alabama', 'arkansas', 'california', 'colorado', 'connecticut', 'delaware', 'district_of_columbia', 'florida', 'georgia', 'hawaii', 'idaho', 'illinois', 'indiana', 'iowa', 'kansas', 'kentucky', 'louisiana', 'maine', 'maryland', 'massachusetts', 'michigan', 'minnesota', 'mississippi', 'missouri', 'montana', 'nebraska', 'nevada', 'new_hampshire', 'new_jersey', 'new_mexico', 'new_york', 'north_carolina', 'north_dakota', 'ohio', 'oklahoma', 'oregon', 'pennsylvania', 'rhode_island', 'south_carolina', 'south_dakota', 'tennessee', 'texas', 'utah', 'vermont', 'virginia', 'washington', 'west_virginia', 'wisconsin', 'wyoming' ); $us_states = array_map( function ( $val ) { $obj = new StdClass(); $obj->$val = $val; return $obj; }, $us_states ); // array_unshift( // array_map( // function ( $val ) { // $obj = new StdClass(); // $obj->$val = $val; // return $obj; // }, // $us_states // ), // new StdClass() // ); var_dump( array_merge( [new StdClass()], $us_states, [new StdClass()] ) );
Output for 5.6.11
array(51) { [0]=> object(stdClass)#1 (0) { } [1]=> object(stdClass)#2 (1) { ["alabama"]=> string(7) "alabama" } [2]=> object(stdClass)#3 (1) { ["arkansas"]=> string(8) "arkansas" } [3]=> object(stdClass)#4 (1) { ["california"]=> string(10) "california" } [4]=> object(stdClass)#5 (1) { ["colorado"]=> string(8) "colorado" } [5]=> object(stdClass)#6 (1) { ["connecticut"]=> string(11) "connecticut" } [6]=> object(stdClass)#7 (1) { ["delaware"]=> string(8) "delaware" } [7]=> object(stdClass)#8 (1) { ["district_of_columbia"]=> string(20) "district_of_columbia" } [8]=> object(stdClass)#9 (1) { ["florida"]=> string(7) "florida" } [9]=> object(stdClass)#10 (1) { ["georgia"]=> string(7) "georgia" } [10]=> object(stdClass)#11 (1) { ["hawaii"]=> string(6) "hawaii" } [11]=> object(stdClass)#12 (1) { ["idaho"]=> string(5) "idaho" } [12]=> object(stdClass)#13 (1) { ["illinois"]=> string(8) "illinois" } [13]=> object(stdClass)#14 (1) { ["indiana"]=> string(7) "indiana" } [14]=> object(stdClass)#15 (1) { ["iowa"]=> string(4) "iowa" } [15]=> object(stdClass)#16 (1) { ["kansas"]=> string(6) "kansas" } [16]=> object(stdClass)#17 (1) { ["kentucky"]=> string(8) "kentucky" } [17]=> object(stdClass)#18 (1) { ["louisiana"]=> string(9) "louisiana" } [18]=> object(stdClass)#19 (1) { ["maine"]=> string(5) "maine" } [19]=> object(stdClass)#20 (1) { ["maryland"]=> string(8) "maryland" } [20]=> object(stdClass)#21 (1) { ["massachusetts"]=> string(13) "massachusetts" } [21]=> object(stdClass)#22 (1) { ["michigan"]=> string(8) "michigan" } [22]=> object(stdClass)#23 (1) { ["minnesota"]=> string(9) "minnesota" } [23]=> object(stdClass)#24 (1) { ["mississippi"]=> string(11) "mississippi" } [24]=> object(stdClass)#25 (1) { ["missouri"]=> string(8) "missouri" } [25]=> object(stdClass)#26 (1) { ["montana"]=> string(7) "montana" } [26]=> object(stdClass)#27 (1) { ["nebraska"]=> string(8) "nebraska" } [27]=> object(stdClass)#28 (1) { ["nevada"]=> string(6) "nevada" } [28]=> object(stdClass)#29 (1) { ["new_hampshire"]=> string(13) "new_hampshire" } [29]=> object(stdClass)#30 (1) { ["new_jersey"]=> string(10) "new_jersey" } [30]=> object(stdClass)#31 (1) { ["new_mexico"]=> string(10) "new_mexico" } [31]=> object(stdClass)#32 (1) { ["new_york"]=> string(8) "new_york" } [32]=> object(stdClass)#33 (1) { ["north_carolina"]=> string(14) "north_carolina" } [33]=> object(stdClass)#34 (1) { ["north_dakota"]=> string(12) "north_dakota" } [34]=> object(stdClass)#35 (1) { ["ohio"]=> string(4) "ohio" } [35]=> object(stdClass)#36 (1) { ["oklahoma"]=> string(8) "oklahoma" } [36]=> object(stdClass)#37 (1) { ["oregon"]=> string(6) "oregon" } [37]=> object(stdClass)#38 (1) { ["pennsylvania"]=> string(12) "pennsylvania" } [38]=> object(stdClass)#39 (1) { ["rhode_island"]=> string(12) "rhode_island" } [39]=> object(stdClass)#40 (1) { ["south_carolina"]=> string(14) "south_carolina" } [40]=> object(stdClass)#41 (1) { ["south_dakota"]=> string(12) "south_dakota" } [41]=> object(stdClass)#42 (1) { ["tennessee"]=> string(9) "tennessee" } [42]=> object(stdClass)#43 (1) { ["texas"]=> string(5) "texas" } [43]=> object(stdClass)#44 (1) { ["utah"]=> string(4) "utah" } [44]=> object(stdClass)#45 (1) { ["vermont"]=> string(7) "vermont" } [45]=> object(stdClass)#46 (1) { ["virginia"]=> string(8) "virginia" } [46]=> object(stdClass)#47 (1) { ["washington"]=> string(10) "washington" } [47]=> object(stdClass)#48 (1) { ["west_virginia"]=> string(13) "west_virginia" } [48]=> object(stdClass)#49 (1) { ["wisconsin"]=> string(9) "wisconsin" } [49]=> object(stdClass)#50 (1) { ["wyoming"]=> string(7) "wyoming" } [50]=> object(stdClass)#51 (0) { } }