Page 1 of 1

explain about arrays please.

Posted: Sun Sep 16, 2007 2:43 am
by spamyboy
If I get my result array:

Code: Select all

Array
(
    [0] => Array
        (
            [id] => 1
            [name] => pirma kategorija
        )

    [1] => Array
        (
            [id] => 2
            [name] => antra kategorija
        )

)
and I need list results like:
<a hred=#id>#name</a>
How should I do it ?
It's not the firt time when I'm having this problem.

Posted: Sun Sep 16, 2007 4:14 am
by jeffery
try this:
Assuming your array is called $my_array

Code: Select all

foreach ($my_array as $index => $record)
{
    echo "<a href=\"{$record['id']}\">{$record['name']}</a>";
}
and readup on the foreach construct at http://php.net/foreach

cheers,
Jeffery