Using raw array text as input for array in PHP

I need to be able to run some built in PHP functions on a large array which came from a corrupted wordpress database of which I have no backups except for a csv file. Specifically the wp_options table is what is messed up because some of the values in the array for the theme the site is using is nested a couple layers too deep and cut off about 100 option values in the option_value db cell.

I would like to be able to salvage the options I have in the original csv and add it to the stock value options that come from the dummy content for that theme and go from there to recoup what I can. Copy/pasting into the database is not working because not all of the values the theme uses are there so it is breaking a php script somewhere.

Read More

The format the text is in is like so:

[data type]:[#items]:[data];
[another type]:[#items]:[more data];

so the real data would look like:

a:3:{s:6:”abcdef”;i:1:5;a:0:{}}

Is there some way I can take this raw text format and input it into a variable in php to use it as an array data type? Essentially I would loop through all the keys in the dummy content array and check if there was a value in the backup array and if so, replace it with the backed up value. If not, leave it there.

Related posts

Leave a Reply

1 comment

  1. The data:

    a:3:{s:6:"abcdef";i:1:5;a:0:{}}
    

    is an array that was serialized with the PHP serialize() function.

    If you run:

    $val = unserialize($serialized_value);
    

    you will get the original values back.