By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,120 Members | 1,799 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,120 IT Pros & Developers. It's quick & easy.

Problem with array - what's wrong??

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
["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.