3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<H2>Funcionamiento de <I>$GLOBALS, each, list y reset</I></H2> <?php $matriz1 = array(0 => "Madrid", 1 => "Valencia", 2 => "Alicante", 3=> "Santander"); $var2; while($var2 = each($matriz1)) { var_dump($var2); echo "<BR />"; } ?> <BR /><BR /><BR /> <?php $matriz2 = $GLOBALS['matriz1']; while(list($pos,$valor) = each($matriz1)) { echo "$pos, $valor<BR />\n"; } ?>
Output for 5.1.0 - 7.1.0
<H2>Funcionamiento de <I>$GLOBALS, each, list y reset</I></H2> array(4) { [1]=> string(6) "Madrid" ["value"]=> string(6) "Madrid" [0]=> int(0) ["key"]=> int(0) } <BR />array(4) { [1]=> string(8) "Valencia" ["value"]=> string(8) "Valencia" [0]=> int(1) ["key"]=> int(1) } <BR />array(4) { [1]=> string(8) "Alicante" ["value"]=> string(8) "Alicante" [0]=> int(2) ["key"]=> int(2) } <BR />array(4) { [1]=> string(9) "Santander" ["value"]=> string(9) "Santander" [0]=> int(3) ["key"]=> int(3) } <BR /> <BR /><BR /><BR /> 0, Madrid<BR /> 1, Valencia<BR /> 2, Alicante<BR /> 3, Santander<BR />
Output for 5.0.4 - 5.0.5
<H2>Funcionamiento de <I>$GLOBALS, each, list y reset</I></H2> Notice: Undefined variable: var2 in /in/H7XAV on line 5 array(4) { [1]=> string(6) "Madrid" ["value"]=> string(6) "Madrid" [0]=> int(0) ["key"]=> int(0) } <BR />array(4) { [1]=> string(8) "Valencia" ["value"]=> string(8) "Valencia" [0]=> int(1) ["key"]=> int(1) } <BR />array(4) { [1]=> string(8) "Alicante" ["value"]=> string(8) "Alicante" [0]=> int(2) ["key"]=> int(2) } <BR />array(4) { [1]=> string(9) "Santander" ["value"]=> string(9) "Santander" [0]=> int(3) ["key"]=> int(3) } <BR /> <BR /><BR /><BR /> 0, Madrid<BR /> 1, Valencia<BR /> 2, Alicante<BR /> 3, Santander<BR />
Output for 4.3.0 - 5.0.3
<H2>Funcionamiento de <I>$GLOBALS, each, list y reset</I></H2> Notice: Undefined variable: var2 in /in/H7XAV on line 5 array(4) { [1]=> string(6) "Madrid" ["value"]=> string(6) "Madrid" [0]=> int(0) ["key"]=> int(0) } <BR />array(4) { [1]=> string(8) "Valencia" ["value"]=> string(8) "Valencia" [0]=> int(1) ["key"]=> int(1) } <BR />array(4) { [1]=> string(8) "Alicante" ["value"]=> string(8) "Alicante" [0]=> int(2) ["key"]=> int(2) } <BR />array(4) { [1]=> string(9) "Santander" ["value"]=> string(9) "Santander" [0]=> int(3) ["key"]=> int(3) } <BR /> <BR /><BR /><BR /> 0, Madrid<BR /> 1, Valencia<BR /> 2, Alicante<BR /> 3, Santander<BR />