Jump to content

array_push or array_merge or array1 + array2... what's wrong with this code?


bgreen52

Recommended Posts

Hi all. Hope this isn't too much of a bother, but what wrong with the code below. I'm trying to modify a shopping cart app that I didn't write to append info to each cart item.

 

code:

$parts = parse_url($referer);

$file = basename($parts['path'],".php");

$ar = array($_REQUEST['add']=>$file);

 

if (!isset($_SESSION['src'])) {

@session_start();

$_SESSION['src'] = array();

}

array_push($_SESSION['src'], $ar);

 

some code precedes the $parts variable to be safe. But the $_SESSION['src'] gets clobbered, not added to. The $_REQUEST['add'] is coming from a var in the URL - the only one. What I end up with is this:

 

session src =

Array

(

    [304] => bernhardt_items

)

 

The next $_REQUEST variable overwrites this one even though the key is different. I'm stumped.

 

Thanks in advance...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.