gdfhghjdfghgfhf Posted May 11, 2008 Share Posted May 11, 2008 well the title says it all.. I have an entry in my database with a serialized array. I'm trying to remove one of the item inside of the array.. Here is the working part of my code $a = $row["options"]; $ary = unserialize($a); foreach ($ary as $thing) { $aff = str_replace("12345 test", "", $thing); echo $aff; } i managed to unserialize the array to take out the entry i wanted (12345 test), but now i need to make a serialized array with the updated items, and i'm stuck here... could anyone help me to complete my code? thanks a lot Quote Link to comment Share on other sites More sharing options...
Barand Posted May 11, 2008 Share Posted May 11, 2008 is "12345 test" an array value or an array key? Forget that, just noticed the indented foreach. try <?php $a = $row["options"]; $ary = unserialize($a); $key = array_search("12345 test", $ary); unset ($ary[$key]); $a = serialize($ary); ?> Quote Link to comment 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.