3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $products = array('Muziek' => 'Brahms', 'DVD' => 'Rambo', 'Blueray' => 'Mozart'); $new_products = array(); foreach ($products as $key => $value){ //echo 'The value of '.$key.' is '.$value.'<br />'; // The value of Muziek is Brahms, etc $new_products[$key] = $value; //$new_products[] = array($key => $value); // multidimensional array met in elke array (2e) 1 name value pair //$new_products[] = array($key => $value, $value => $key ); // multidimensional array met in elke array (2e) een name value pair en dus een value name pair } echo '<pre>';print_r($new_products);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
<pre>Array ( [Muziek] => Brahms [DVD] => Rambo [Blueray] => Mozart )