|
Posted by Robert Cummings on 10/26/05 07:50
On Wed, 2005-10-26 at 00:28, Ken Tozier wrote:
> I'm having a major problem with what seems, on it's face, to be a
> really basic array function.
>
> What happens is on the browser end, I've written some javascript code
> that packages up javascript variables in native PHP format and sends
> the packed variables to a PHP script on the server via a POST and
> XMLHTTP. On the server end, the PHP script grabs the packed variables
> out of the $_POST, strips slashes and uses the "unserialize" command.
>
> Here's the function that gets the post data
> $unpacked_data = GetDataFromPOST();
>
> And here's a var_dump of $unpacked_data as it appears in the browser
> array(1) { ["handler"]=> array(1) { ["0"]=> string(9)
> "databases" } }
>
> I'm able to get the "handler with no problem like so:
> $parts = $unpacked_data['handler'];
>
> Which yields the following var_dump
> array(1) { ["0"]=> string(9) "databases" }
I did the following as a test:
<?php
$unpacked_data = array
(
'handler' => array
(
'0' => 'databases',
),
);
?>
var_dump( $unpacked_data );
and I did...
<?php
$unpacked_data = array
(
'handler' => array
(
"0" => 'databases',
),
);
var_dump( $unpacked_data );
?>
I also tried:
<?php
$unpacked_data = array
(
'handler' => array
(
'"0"' => 'databases',
),
);
var_dump( $unpacked_data );
?>
But no matter what I did I could NOT get var_dump to dump my 0 key for
the 'databases' as you have in your output. So methinks therein may lie
your problem. Perhaps during the serialization in javascript check if
the key is an integer-like string and if so then convert to an integer
for the key serialization.
Let us know if it works :)
Cheers,
Rob.
--
..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
Navigation:
[Reply to this message]
|