Here’s what I was trying to do:
but I kept getting this error:
unserialize() [function.unserialize]: Error at offset 0 of 3457 bytes
I looked around and couldn’t find a simple a solution. I’m sure this error can occur in other ways, but I was trying with the simplest of arrays:
Array("Ryan" => "Bosinger");
My problem was that my echo statement was throwing some whitespace in there. That’s all. This fixed it:
$data["search_results"] = file_get_contents("http://localhost/sphider/search.php?query=" . $search_for . "&search=1&start=" . $start); $result_string = trim($data["search_results"]); $result_array = unserialize($result_string);
Basically, try trimming the whitespace before unserializing. Hope that helps!
Also, I was using Codeigniter but I really don’t think that has anything to do with it.
Understanding how a programming language works is a surefire way to be a better developer. Read more.