3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $pet1 = 'dog'; $pet2 = 'cat'; $arrayvalue = array( array('brown', 'white'), array($pet1, $pet2) ); // echo both parts: for ($i=0; $i<2; $i++) echo $arrayvalue[0][$i] . ' ' . $arrayvalue[1][$i] . '<br>'; echo "\n"; //echo just the first part: echo $arrayvalue[0][0] . ' ' . $arrayvalue[1][0]; echo "\n"; //echo just the second part: echo $arrayvalue[0][1] . ' ' . $arrayvalue[1][1]; echo "\n"; //echo just "brown white": echo $arrayvalue[0][0] . ' ' . $arrayvalue[0][1]; echo "\n"; //echo just "dog cat": echo $arrayvalue[1][0] . ' ' . $arrayvalue[1][1]; echo "\n"; //echo both "brown white" and "dog cat": foreach ($arrayvalue as $a) echo $a[0] . ' ' . $a[1] . '<br>';
Output for 4.3.0 - 7.1.0
brown dog<br>white cat<br> brown dog white cat brown white dog cat brown white<br>dog cat<br>