PHP array key nightmare

Hi …:slight_smile:

Have recently started in PHP.
Have rebuilt a page to add functionality.
At the end of a build I have an array that outputs values like this which i use on the next page.

Array (
[0] => stdClass Object ( [imageName] => homebtn.png [name] => Shawn Product 1 [price] => 200.00 [id] => 1 )
[1] => stdClass Object ( [imageName] => homebtnrollover.png [name] => Shawn 2 [price] => 200.00 [id] => 2 )
[2] => stdClass Object ( [imageName] => e.jpg [name] => fff [price] => 345.00 [id] => 6 ) )

This format does work on the page I want to use it on, so I have tried to change the page to accept my values, but its not working, as the ripple is huge.

If i can get my array output to look the the original output, like this:

Array (
[facebook.png] => Array (
[0] => New Brand,New Product,New Desc,200.001 )
[homebtn.png] => Array (
[0] => Deci,Decimal Prod 1,Deci Description,854.991 )
[241-0.htm] => Array (
[0] => MUSCLE MEDS,Deci Prod 3,Prod 3 deci,50.101 ) )

How do i manipulate my array at top, to look the same as the below output?
Thanks.

$SQL = “SELECT imageName, name, price, id FROM product WHERE id = ‘$ID’”;
$query = mysql_query($SQL);
while ($productresult[] = mysql_fetch_object( $query ) );
array_pop ($productresult);
}

Fields are - ImageName, Name, price, description, id

I dont need that 1 at the end of the 2cnd array, and i do nt need ID from the top array.

Thanks for the help.

On page load…

<?php function super_unique($array) { $result = array_map("unserialize", array_unique(array_map("serialize", $array))); foreach ($result as $key => $value) { if ( is_array($value) ) { $result[$key] = array_values(super_unique($value)); } else { } } return $result; } if(!$_SESSION['options1']){ if(isset($_POST['options'])){ $_SESSION['options1'] = $_POST['options']; } } else{ $oldArray = $_SESSION['options1']; if(isset($_POST['options'])){ unset($_SESSION['options1']); //$_SESSION['options1'] = $_POST['options'] + $oldArray; $res = array_merge_recursive($_POST['options'], $oldArray); $_SESSION['options1'] = super_unique($res); unset($oldArray); } } print_r($_SESSION['options1']); if (!empty($_SESSION['options1'])){ foreach($_SESSION['options1'] as $value){ for ($i=0; $i < count($value); $i++) { $prices[] = explode(",", $value[$i]); } $count = count($prices); for ($i=0; $i < $count; $i++) { $res[] = '#spinner_'.$i; } } } ?>

foreach($_SESSION[‘options1’] as $key => $value){

This is where the code is used…
The output in the 2cnd array is the values used here…

}

Sponsor our Newsletter | Privacy Policy | Terms of Service