3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(E_ALL); ?> <HTML> <HEAD> <TITLE>Trabajando con matrices</TITLE> <META CHARSET="UTF-8" /> </HEAD> <BODY> <CENTER> <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 $GLOBALS['matriz1']; while(list($pos,$valor) = each($matriz1)) { echo "$pos, $valor<BR />\n"; } ?> </CENTER> </BODY> </HTML>
Output for 5.1.0 - 5.6.28, 7.0.0 - 7.1.0
<HTML> <HEAD> <TITLE>Trabajando con matrices</TITLE> <META CHARSET="UTF-8" /> </HEAD> <BODY> <CENTER> <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 /> </CENTER> </BODY> </HTML>
Output for 5.0.4 - 5.0.5, hhvm-3.12.0
<HTML> <HEAD> <TITLE>Trabajando con matrices</TITLE> <META CHARSET="UTF-8" /> </HEAD> <BODY> <CENTER> <H2>Funcionamiento de <I>$GLOBALS, each, list y reset</I></H2> Notice: Undefined variable: var2 in /in/AXYXi on line 13 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 /> </CENTER> </BODY> </HTML>
Output for hhvm-3.10.0
<HTML> <HEAD> <TITLE>Trabajando con matrices</TITLE> <META CHARSET="UTF-8" /> </HEAD> <BODY> <CENTER> <H2>Funcionamiento de <I>$GLOBALS, each, list y reset</I></H2> Notice: Undefined variable: var2 in /in/AXYXi on line 23 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 /> </CENTER> </BODY> </HTML>
Output for 4.3.0 - 5.0.3
<HTML> <HEAD> <TITLE>Trabajando con matrices</TITLE> <META CHARSET="UTF-8" /> </HEAD> <BODY> <CENTER> <H2>Funcionamiento de <I>$GLOBALS, each, list y reset</I></H2> Notice: Undefined variable: var2 in /in/AXYXi on line 13 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 /> </CENTER> </BODY> </HTML>