Asked  2 Years ago    Answers:  5   Viewed   80 times

I have a massive multidimensional array that has been serialised by PHP. It has been stored in MySQL and the data field wasn't large enough... the end has been cut off... I need to extract the data... unserialize wont work... does anyone know of a code that can close all the arrays... recalculate string lengths... it's too much data to do by hand.

Many thanks.



I think this is almost impossible. Before you can repair your array you need to know how it is damaged. How many childs missing? What was the content?

Sorry imho you can't do it.



$serialized = serialize(
        'one'   => 1,
        'two'   => 'nice',
        'three' => 'will be damaged'

var_dump($serialized); // a:3:{s:3:"one";i:1;s:3:"two";s:4:"nice";s:5:"three";s:15:"will be damaged";}

var_dump(unserialize('a:3:{s:3:"one";i:1;s:3:"two";s:4:"nice";s:5:"tee";s:15:"will be damaged";}')); // please note 'tee'

var_dump(unserialize('a:3:{s:3:"one";i:1;s:3:"two";s:4:"nice";s:5:"three";s:')); // serialized string is truncated


Even if you can recalculate length of your keys/values, you cannot trust the data retrieved from this source, because you cannot recalculate the value of these. Eg. if the serialized data is an object, your properties won't be accessible anymore.

Saturday, November 19, 2022

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario:

Related usability ticket:

P.S. The WI-18388 ticket is already fixed in v8.0

Sunday, July 31, 2022


Your initial expression simply finds the entire block of text which represents each key and value set. Then in your clean up section, you're looking for a close paran which is followed immediately by a end of string )$ but I'm sure there are additional characters between the close paran and the end of the string.

Instead I'd handle all this in one operation. This expression will:

  • find the field value
    • trim the surrounding parens off
    • and place into capture group 1
  • find the name of the value and place into capture group 2
    • trim the field_ substring off
    • trim the surrounding parens off
    • and place into capture group 2
  • requires the options: case insensitive, and multi-line



Live Demo

Sample Text

1 0 obj 
/Fields [
/V ([email protected])
/T (field_email)
/V (John)
/T (field_name)
/V ()
/T (field_reference)

/Root 1 0 R


[0][0] = /V ([email protected])
/T (field_email)
[0][1] = [email protected]
[0][2] = email

[1][0] = /V (John)
/T (field_name)
[1][1] = John
[1][2] = name

[2][0] = /V ()
/T (field_reference)
[2][1] = 
[2][2] = reference


If you wanted retain the field_ substring, then you can simply remove that from the expression like so:


Saturday, October 15, 2022

dataTables child rows dynamically injects a row on the form

<tr colspan="number of columns">
      ... user content ... 

user content is passed to the injected row upon the call (from the example) :

row.child(<user content>).show();

You cannot use hidden rows as a base for child rows. I would suggest you collect all the content you output to hidden rows in the loop into a javascript array :

var content = [];

content[<? echo $storageItem['unique_id']; ?>] = '"'+<? echo form_open(...) + everything from your .hiddenRow. Now follow the example, populate each <tr> with the unique_id

<tr uniqueId="<? echo $storageItem['unique_id']; ?>">

dedicate one column to activate the child row by adding a .details-control and instead of calling the function format() as in the example, do a


Update. Jguy, what about

1) fist make your code to work only by inserting simple content. For example row.child('hello').show(); By that you will know that part is working.

2) Then, build up the content array separetely. You do not have to do it all in the same foreach(). This may improve the chance of success if you split the things up in "logical" operations.

3) remember to set an item_id on the <tr>'s

4) your dataTables version cannot be outdated in this context as long as you are using 1.10.x

Wednesday, August 17, 2022

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Sunday, November 6, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :

Browse Other Code Languages