467,074 Members | 918 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,074 developers. It's quick & easy.

Problem with array - what's wrong??

Hi.

I'm using

<pre><?php print_r($_POST['dane']); ?>
</pre>
and i'm getting this:

Array
(
[1] => Array
(
[\'zamow\'] => Array
(
[0] => 1
)

)}

So then i tried

<pre><?php print_r($_POST['dane'][1]); ?>
</pre>

Array
(
[\'zamow\'] => Array
(
[0] => 1
)

)But when i'm trying with:<pre><?php print_r($_POST['dane'][1]['zamow']); ?>
</pre>I'm getting no resultsWhat is wrong? What should to see result?

Thanks
Leszek

Feb 1 '06 #1
  • viewed: 1025
Share:
1 Reply
["Followup-To:" header set to comp.lang.php.]
Leszek wrote:
<pre><?php print_r($_POST['dane']); ?>
</pre>
and i'm getting this:

Array
(
[1] => Array
(
[\'zamow\'] => Array <snip>
<pre><?php print_r($_POST['dane'][1]); ?>
</pre>

Array
(
[\'zamow\'] => Array <snip>
)But when i'm trying with:<pre><?php print_r($_POST['dane'][1]['zamow']); ?>
</pre>I'm getting no resultsWhat is wrong? What should to see result?


The single quotes are part of the array index. If you want to print its
value you need to include the single quotes

<?php print_r($_POST['dane'][1]['\'zamow\'']); ?>

or

<?php print_r($_POST['dane'][1]["'zamow'"]); ?>

or even

<?php
$idxA = 'dane';
$idxB = 1;
$idxC = "'zamow'";
print_r($_POST[$idxA][$idxB][$idxC]);
?>

--
If you're posting through Google read <http://cfaj.freeshell.org/google>
Feb 1 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

18 posts views Thread by mrvendetta1@yahoo.com | last post: by
11 posts views Thread by Leszek | last post: by
39 posts views Thread by Martin Jørgensen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.