Page 1 of 1

need help with trim please

Posted: Fri Sep 10, 2004 7:59 am
by kholloi
Hi I am trying to remove whitespace from array ellements.

I came up with this:

Code: Select all

$file = file("/etc/sysconfig/network/ifcfg-$if");

//Clean whitespace from array ellements

for($i = 0; $i <= 8; $i++)
&#123;
trim($file&#1111;$i]);
&#125;

echo var_dump($file);

But the whitespace remains. Here is the output of var_dump():
array(9) {
[0]=>
string(19) "BOOTPROTO='static'
"
[1]=>
string(26) "BROADCAST='192.168.1.255'
"
[2]=>
string(23) "IPADDR='192.168.1.153'
"
[3]=>
string(7) "MTU=''
"
[4]=>
string(24) "NETMASK='255.255.255.0'
"
[5]=>
string(22) "NETWORK='192.168.1.0'
"
[6]=>
string(17) "REMOTE_IPADDR=''
"
[7]=>
string(19) "STARTMODE='onboot'
"
[8]=>
string(26) "UNIQUE='QXTf.TgVqGjtNpC0'
"
}
Are there any obvious mistakes?

THanks

Posted: Fri Sep 10, 2004 8:26 am
by Weirdan
yep. use this instead:

Code: Select all

//....
$file[$i] = trim($file[$i]);
//....