3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $prodQueryResult =array('PRODUCT1'=>'prod1','QUANTITY1'=>'quan1','PRODUCT2'=>'prod2','QUANTITY2'=>'quan2','PRODUCT3'=>'prod3','QUANTITY3'=>'quan3','PRODUCT4'=>'prod4','QUANTITY4'=>'quan4','PRODUCT5'=>'prod5','QUANTITY5'=>'quan5','PRODUCT6'=>'prod6','QUANTITY6'=>'quan6','PRODUCT7'=>'prod7','QUANTITY7'=>'quan7'); $i=6; foreach($prodQueryResult as $prod) { $count=$i; $p = "PRODUCT".$i; $q = "QUANTITY".$i; //echo $q."\n"; echo "<pre>",print_r($prod); $i++; }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
<pre>prod11<pre>quan11<pre>prod21<pre>quan21<pre>prod31<pre>quan31<pre>prod41<pre>quan41<pre>prod51<pre>quan51<pre>prod61<pre>quan61<pre>prod71<pre>quan71