- print_r: documentation ( source)
<?php
$array = array('red', 'white', 'blue');
$new_array = array();
$temp_array = &$new_array;
foreach ($array as $item)
{
$temp_array = &$temp_array['and'];
// $temp_array now equals null,
// and it's references to parent array item with key and
$temp_array['like'] = $item;
}
unset($temp_array);
print_r($new_array);