Converting stringified array into actual array

The DB I am working with has an array of strings stored as a text value, such as:

“[\”Radio\/CD\”,\”TV\”,\”Weight Gauge\”]”

(no idea why stored like this)

Anyway, I need to convert it into a regular array, such as:

Array (
[0] => Weight Gauge
[1] => TV
[2] => Radio/CD )

Because of the way its stored I can’t do a regular php explode, eg:

<?php
    $input  = '"[\"Radio\\\/CD\",\"TV\",\"Weight Gauge\"]"';
    echo "Input string:<br>" . $input . "<br><br>";
    $output = explode(",", stripslashes($input));
    print_r($output);
?>

The resulting array ( not how I want it ):

Array ( [0] => “[“Radio/CD” [1] => “TV” [2] => “Weight Gauge”]” )

Thanks

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s