bgreen52 Posted March 3, 2009 Share Posted March 3, 2009 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... Link to comment https://forums.phpfreaks.com/topic/147664-array_push-or-array_merge-or-array1-array2-whats-wrong-with-this-code/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.