Jump to content

Archived

This topic is now archived and is closed to further replies.

bilis_money

How would you print this array values?

Recommended Posts

guys?

ok, let say i have these array structure:

[code]
Array
(
    [s_id] => 91
    [s_photo_filename] => logo03.gif
    [s_tmp_name] =>
    [s_type] => image/gif
    [s_size] => 4612
    [s_path] =>
    [s_date] => 2006-06-25
    [s_comments] => TEsting, testing
    [s_photo_category] =>
)
[/code]

now i know that the keys of the array are in string and not in intergers.
how would you loop and move the array pointer from 0 to 9?

i know these codes below are not possible because the array keys is in strings.
[code]
while($i < 9) {
$result = $_session[$i]; //this will not work
echo "$i: ". $result. "<br>";
$i++;
}
[/code]

now what's your way of solving this?


thanks in advance.

Share this post


Link to post
Share on other sites
I think this will do it:
[code]
$i=0;
foreach($arrayName as $key=>$value) {
$result = $_session[$key]; //this will not work
echo "$i: ". $result. "<br>";
$i++;
$i++;
}[/code]

Share this post


Link to post
Share on other sites
ok thanks i'll try to understand foreach again.
i have just forgot the essence of it.

thanks anyway.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.