Multi-dimensional Array

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Multi-dimensional Array

    Hi,

    Array-Question:

    Suppose you have an array like:
    <?
    $invoices[$invoicenumber][taxrate.$taxrate]=$taxrate;
    $invoices[$invoicenumber][turnover.$taxrate]=a number;
    ?>


    Now:
    <?
    while(list($key,$val)=each($invoces[xxxxx)) {
    echo "$key - $val";
    }
    ?>
    shows a neat list..

    Now,
    Is there a possibility to access an item of this array direct?
    e.g. suppose you have diffrent tax-rates, and want to know the value of:
    $invoices[$invoicenumber][taxrate.$taxrate] if you have the
    invoicenumber???
    echo $invoices[12345][0]; (the first item of the array-stack)
    returns: Array[0]

    and suppose taxrate=6:
    echo $invoices[12345][turnover6]; returns: Array[turnover6]

    Somebody knows how to get the value(s) of this without the loop?

    Thanx in advance,

    Marco Snoek


    Marco Snoek Guest

  2. Similar Questions and Discussions

    1. Filtering the elements of a multi-dimensional array
      I would like to be able to filter every element of a multi-dimensional array using htmlspecialchars() and to retain the structure of the array. I...
    2. assigning a multi-dimensional array (mda) to an mda?
      Hi all, Quiet but not idle... I'm working on localization -- placing all text labels, etc. into one subsection; this made things so easy I...
    3. #24620 [Bgs]: Error multi dimensional array
      ID: 24620 User updated by: fadfdsj at libero dot it Reported By: fadfdsj at libero dot it Status: Bogus Bug Type: ...
    4. #24620 [Opn->Bgs]: Error multi dimensional array
      ID: 24620 Updated by: sniper@php.net Reported By: fadfdsj at libero dot it -Status: Open +Status: ...
    5. #24620 [Opn]: Error multi dimensional array
      ID: 24620 User updated by: fadfdsj at libero dot it Reported By: fadfdsj at libero dot it Status: Open Bug Type: ...
  3. #2

    Default Re: Multi-dimensional Array

    If I understand you might need array_values() function....

    Check the manual....

    hope this helps....

    "Marco Snoek" <[mps]@DONT _
    YOU^DARE%SEND/SPAM!!!@remove/this[@webmind.nl]@remove/this> wrote in message
    news:3f70021b$0$58712$e4fe514c@news.xs4all.nl...
    > Hi,
    >
    > Array-Question:
    >
    > Suppose you have an array like:
    > <?
    > $invoices[$invoicenumber][taxrate.$taxrate]=$taxrate;
    > $invoices[$invoicenumber][turnover.$taxrate]=a number;
    > ?>
    >
    >
    > Now:
    > <?
    > while(list($key,$val)=each($invoces[xxxxx)) {
    > echo "$key - $val";
    > }
    > ?>
    > shows a neat list..
    >
    > Now,
    > Is there a possibility to access an item of this array direct?
    > e.g. suppose you have diffrent tax-rates, and want to know the value of:
    > $invoices[$invoicenumber][taxrate.$taxrate] if you have the
    > invoicenumber???
    > echo $invoices[12345][0]; (the first item of the array-stack)
    > returns: Array[0]
    >
    > and suppose taxrate=6:
    > echo $invoices[12345][turnover6]; returns: Array[turnover6]
    >
    > Somebody knows how to get the value(s) of this without the loop?
    >
    > Thanx in advance,
    >
    > Marco Snoek
    >
    >

    point Guest

  4. #3

    Default Re: Multi-dimensional Array ==> solved

    I found a work-around with

    $needed = array_key(array_slice($invoces[$invocenumber],3,5));
    (by head.. typo???)

    But more problems appear, so I put it aside.. :-)

    Thanx anyway :-)))



    "point" <point@caanNOproductionSPAM.com> schreef in bericht
    news:bkq0gd01cit@enews3.newsguy.com...
    > If I understand you might need array_values() function....
    >
    > Check the manual....
    >
    > hope this helps....
    >
    > "Marco Snoek" <[mps]@DONT _
    > YOU^DARE%SEND/SPAM!!!@remove/this[@webmind.nl]@remove/this> wrote in
    message
    > news:3f70021b$0$58712$e4fe514c@news.xs4all.nl...
    > > Hi,
    > >
    > > Array-Question:
    > >
    > > Suppose you have an array like:
    > > <?
    > > $invoices[$invoicenumber][taxrate.$taxrate]=$taxrate;
    > > $invoices[$invoicenumber][turnover.$taxrate]=a number;
    > > ?>
    > >
    > >
    > > Now:
    > > <?
    > > while(list($key,$val)=each($invoces[xxxxx)) {
    > > echo "$key - $val";
    > > }
    > > ?>
    > > shows a neat list..
    > >
    > > Now,
    > > Is there a possibility to access an item of this array direct?
    > > e.g. suppose you have diffrent tax-rates, and want to know the value
    of:
    > > $invoices[$invoicenumber][taxrate.$taxrate] if you have the
    > > invoicenumber???
    > > echo $invoices[12345][0]; (the first item of the array-stack)
    > > returns: Array[0]
    > >
    > > and suppose taxrate=6:
    > > echo $invoices[12345][turnover6]; returns: Array[turnover6]
    > >
    > > Somebody knows how to get the value(s) of this without the loop?
    > >
    > > Thanx in advance,
    > >
    > > Marco Snoek
    > >
    > >
    >
    >

    Marco Snoek Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139