Problem with array - what's wrong??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leszek

    #1

    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



  • Pedro Graca

    #2
    Re: Problem with array - what's wrong??

    ["Followup-To:" header set to comp.lang.php.]
    Leszek wrote:[color=blue]
    > <pre><?php print_r($_POST['dane']); ?>
    > </pre>
    > and i'm getting this:
    >
    > Array
    > (
    > [1] => Array
    > (
    > [\'zamow\'] => Array[/color]
    <snip>
    [color=blue]
    > <pre><?php print_r($_POST['dane'][1]); ?>
    > </pre>
    >
    > Array
    > (
    > [\'zamow\'] => Array[/color]
    <snip>
    [color=blue]
    > )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?[/color]

    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>

    Comment

    Working...