Page 1 of 1

Help with formatting array data

Posted: Fri Jul 01, 2005 9:24 am
by mhouldridge
Hi,

I have array data which I need to format. Currently the output looks like this;

[0] => 192.168.241.1
[1] => 192.168.241.2
[2] => 192.168.241.3
[3] => 192.168.241.5
[4] => 192.168.241.7

and my script to output this is as follows;

Code: Select all

echo'<pre>';
print_r($available_ips); 
echo '</pre>'
Is there anyway to html format this or to simply take out the "[0] =>" part so that the IPs are the only thing shown?

thanks in advance

Posted: Fri Jul 01, 2005 9:42 am
by Chris Corbyn
print_r() is intended more as a debug function, not for presentation.

To get the actual details you need use a foreach loop. For example....

Code: Select all

foreach($available_ips as $value) {
    echo $value.'<br />';
}

Posted: Fri Jul 01, 2005 9:45 am
by mhouldridge
ah,

Thankyou!