Jump to content

unserialize array, remove an item, then serialize the new array


Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.