Log in

View Full Version : unserialize problem


Revan
07-30-2004, 07:53 PM
Ive got a bit of serialized text, with this value:
s:8:"NeoRevan";s:11:"Burnzaquist";
Now when I hit unserialize, I get only "NeoRevan" (without the quotes). It seems to have deleted the other string.

What can be done about this?

Xenon
07-31-2004, 11:07 AM
can you please post the complete serialized text?

if you have two strings, then it must be an array, so the array code serializing string would be needed :)

Revan
07-31-2004, 12:54 PM
w00000000000000t!
I managed to solve the problem, and believe it or not YOU Xenon put me onto the right track with your talk of arrays :D :D :D :D :D

Now all I need is to comma seperate the names after the unserialize.....



I think this ++++ might actually help with the RPG conversion as well :D :D
If thats true then I will start worshipping Xenon XD

Xenon
07-31-2004, 02:28 PM
comma separate?

you might love this function:
http://de3.php.net/manual/en/function.implode.php

Revan
07-31-2004, 03:42 PM
nah that didnt work.
But it doesnt look too lame as it does, it just displays an extra comma behind the last name :P

Thanks for ye olde helpe :D

Xenon
07-31-2004, 04:06 PM
hmm, implode doesn't add a comma behind the last entry, so you have to make, sure that the last name is also really the last entry.

So an array:
1 => 'Test',
2 => 'Name',
3 => ''

will give an imploded string: 'Test,Name,'

but if you have a correct array
1 => 'Test',
2 => 'Name'

it will result in: 'Test,Name'

Revan
07-31-2004, 05:40 PM
No what I said was that the implode itself didnt work.
It didnt implode the comma as it was supposed to.
As of now I got
foreach ($array as $v1)
{
foreach ($v1 as $v2)
{
echo "$v2, ";
}
}

And yes there needs to be 2 foreach cos the array is

Array (
[0] => array (
[username] => "Username 1"
)
[1] => array (
[username] => "username 2"
)
)

And the array will change number of values based on how many usernames there are.

lol dont ask me how the arrays got stored so silly, I took vB3's own query and modded it to my own need for it. ;)

Xenon
08-01-2004, 11:17 AM
ahh, ok, if you have such an array, then implode won't work, you're right ;)