note 79339 added to function.serialize

From: Date: Wed, 21 Nov 2007 17:50:50 +0000
Subject: note 79339 added to function.serialize
Groups: php.notes 
Request: Send a blank email to php-notes+get-132470@lists.php.net to get a copy of this message
serialize() and unserialize() behave a bit crazy if you try to work with bigger strings (100kb of size). It helps to divide the string parts to array: <?php // string in $data $ko = 4096; $data2 = array(); for($i=0;$i<ceil(strlen($data) / $ko);$i++) { $data2[] = substr($data,($i * $ko),(($i+1) * $ko)); } // prepared array in $data2 ?> ...before serialize() and <?php // array in $data2 $data = ''; for($i=0;$i<count($data2);$i++) { $data .= $data2[$i]; } // your string in $data ?> ...after unserialize() ---- Server IP: 147.32.160.17 Probable Submitter: 62.168.34.44 ---- Manual Page -- http://www.php.net/manual/en/function.serialize.php Edit -- https://master.php.net/note/edit/79339 Del: integrated -- https://master.php.net/note/delete/79339/integrated Del: useless -- https://master.php.net/note/delete/79339/useless Del: bad code -- https://master.php.net/note/delete/79339/bad+code Del: spam -- https://master.php.net/note/delete/79339/spam Del: non-english -- https://master.php.net/note/delete/79339/non-english Del: in docs -- https://master.php.net/note/delete/79339/in+docs Del: other reasons-- https://master.php.net/note/delete/79339 Reject -- https://master.php.net/note/reject/79339 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132470) next »