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( $us_states ); // var_dump( array_merge( [new StdClass()], $us_states ) );
Output for 5.6.11
Strict Standards: Only variables should be passed by reference in /in/69tHq on line 32 array(49) { [0]=> string(7) "alabama" [1]=> string(8) "arkansas" [2]=> string(10) "california" [3]=> string(8) "colorado" [4]=> string(11) "connecticut" [5]=> string(8) "delaware" [6]=> string(20) "district_of_columbia" [7]=> string(7) "florida" [8]=> string(7) "georgia" [9]=> string(6) "hawaii" [10]=> string(5) "idaho" [11]=> string(8) "illinois" [12]=> string(7) "indiana" [13]=> string(4) "iowa" [14]=> string(6) "kansas" [15]=> string(8) "kentucky" [16]=> string(9) "louisiana" [17]=> string(5) "maine" [18]=> string(8) "maryland" [19]=> string(13) "massachusetts" [20]=> string(8) "michigan" [21]=> string(9) "minnesota" [22]=> string(11) "mississippi" [23]=> string(8) "missouri" [24]=> string(7) "montana" [25]=> string(8) "nebraska" [26]=> string(6) "nevada" [27]=> string(13) "new_hampshire" [28]=> string(10) "new_jersey" [29]=> string(10) "new_mexico" [30]=> string(8) "new_york" [31]=> string(14) "north_carolina" [32]=> string(12) "north_dakota" [33]=> string(4) "ohio" [34]=> string(8) "oklahoma" [35]=> string(6) "oregon" [36]=> string(12) "pennsylvania" [37]=> string(12) "rhode_island" [38]=> string(14) "south_carolina" [39]=> string(12) "south_dakota" [40]=> string(9) "tennessee" [41]=> string(5) "texas" [42]=> string(4) "utah" [43]=> string(7) "vermont" [44]=> string(8) "virginia" [45]=> string(10) "washington" [46]=> string(13) "west_virginia" [47]=> string(9) "wisconsin" [48]=> string(7) "wyoming" }