Professional Web Applications Themes

make array cell = array? - PHP Development

I want to make a 2D array quickly $item = an array with the associative names ['name'], ['category'], ['price'] etc... I want to do: $items_array[$i] = $item $i++ This doesn't seem to work, because I can't make an array cell equal to another array. How do I get around this?...

  1. #1

    Default make array cell = array?

    I want to make a 2D array quickly

    $item = an array with the associative names ['name'], ['category'],
    ['price'] etc...

    I want to do:

    $items_array[$i] = $item
    $i++

    This doesn't seem to work, because I can't make an array cell equal to
    another array.
    How do I get around this?



    Kevin Torr Guest

  2. #2

    Default Re: make array cell = array?

    *** Kevin Torr wrote/escribió (Wed, 11 Feb 2004 00:42:01 +1100):
    > $item = an array with the associative names ['name'], ['category'],
    > ['price'] etc...
    >
    > $items_array[$i] = $item
    > $i++
    If it's an associative array, keys aren't integers but strings. You need
    another method:

    foreach (array_expression as $value) statement
    foreach (array_expression as $key => $value) statement


    --
    --
    -- Álvaro G. Vicario - Burgos, Spain
    --
    Alvaro G Vicario Guest

  3. #3

    Default Re: make array cell = array?

    "Alvaro G Vicario" <alvaro_QUITAR_REMOVEtelecomputeronline.com> wrote in
    message news:hrcth0p7llvy.1fjrqxrzj3ybz.dlg40tude.net...
    > *** Kevin Torr wrote/escribió (Wed, 11 Feb 2004 00:42:01 +1100):
    > > $item = an array with the associative names ['name'], ['category'],
    > > ['price'] etc...
    > >
    > > $items_array[$i] = $item
    > > $i++
    >
    > If it's an associative array, keys aren't integers but strings. You need
    > another method:
    >
    > foreach (array_expression as $value) statement
    > foreach (array_expression as $key => $value) statement
    What about the case where the array is both associative and integer? (in the
    case of the MYSQL_BOTH for mysql_fetch_array()) ???

    Thanks


    Kevin Torr Guest

Similar Threads

  1. How to interrogate array cell?
    By Richard Heintze in forum PERL Beginners
    Replies: 4
    Last Post: February 10th, 05:35 PM
  2. array data matches but array created in loop doesn't work
    By Reed Law in forum PHP Development
    Replies: 1
    Last Post: August 13th, 04:25 AM
  3. #24897 [Com]: array_multisort() will reindex the array but not if array length is 1
    By franklin_se at hotmail dot com in forum PHP Development
    Replies: 0
    Last Post: August 2nd, 03:29 PM
  4. Replies: 0
    Last Post: August 1st, 12:02 PM
  5. how to make a global scope array
    By Comex in forum PHP Development
    Replies: 5
    Last Post: July 26th, 02:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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