woza Posted April 3, 2010 Share Posted April 3, 2010 Hi everyone I wondered if anyone could help me out with some code for a Zen Cart site I run. Basically I wanted to create a script so when someone add's an item to the cart the shopping cart button changes from "add to cart" to "add another". I managed to find out Zen Cart stores cart info in a array, which has the product id so I created the below script: if ($_SESSION['cart']->in_cart($_GET['products_id'])) { $BUTTONIMAGEINCART = 'cart/button_in_cart_5b.png'; } else { $BUTTONIMAGEINCART = 'cart/button_in_cart_5.png';} This seem to work fine until I noticed it didn't work for all products. So I checked the contents of the array and found for some strange reason zen cart adds a session id after the product id. So instead of Array ( [id] => 1841 .... It puts: Array ( [id] => 1477:a4e70f439369b7abdecbcb784aa75ba7 .... which stops my method from working. Does any know how I can get around this. Either by stripping off the id in array or getting it to read only the part before the : ? Any help would be greatly appreciated. Many thanks Warren Quote Link to comment https://forums.phpfreaks.com/topic/197458-matching-data-in-an-array/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.