No, we simply provided a method of achieving the desired effect due to the lack of specification on your part:AKA Panama Jack wrote:Everyone IGNORED the fact it should NOT use the unserialize function from PHP in any fashion.
1) Does the data need to be loaded into an array or will it be outputted on the spot
(either way the methods me and feyd posted solve the problem)
2) WHY must the data not be loaded into an array, perhaps there is an alternate solution to your problem
No one is going to walk you through re-creating an existing PHP function just so you can avoid a 'temp' array (even though re-creating it would still require a temp array).
You have refused to address the issue of what exactly you are doing with the data, are you going to load it into an array and modify / display it somewhere else, if so the only con to using the native PHP functions are the data storage format itself. List one thing the unserialize() function cannot do that your function would be able to do, no "it loads the variables when I don't want it to" is NOT a valid answer.
To further add to these arguments your pseudocode posted early on in the thread:
Code: Select all
$unserialized_list = unserialize_function($serialized_data); // this is a function that converts the serialised string into an array of what each variable in the array actually isAlso please avoid further rude statements that imply ignorance on our [all the responses in this thread] part by stating that we are ignoring you when we are simply providing code based on your specifications
-------------------------------------------------------------------------------------------------------------------
but foreach operates on a copy of the array, how about this:feyd wrote:it is jshpro2, but it doesn't need the "temporary" variable to store the output from unserialize() foreach does that for you
Code: Select all
$array = unserialize($somedata);
if (!$count=count($array)) {
echo 'failed';
} else {
for ($i=0;$i<$count;$i++) {
// foo
}
}