Hi all,
I m realy thank full to this forum it gave me really help in time.I am facing a problem i have an array in which a trailing slash is appearing,So i need to remove that slash below is the out put.and this array is dynamic it mean next time when i run the code i don't know where slash will appear.can any one help me with this.For reference see index 4
sudo php write.php
Array
(
[0] => /var/www/html
[1] => /test/abc/xyx
[2] => /var/www/wsite/c-clientx1.awpdc.com/htdoc
[3] => /var/www/wsite/c-clientx1.awpdc.com/htdoc2
[4] => /var/www/wsite/www.mytriptrace.com/htdoc/
[5] => /var/www/wsite/www.mytriptrace.com/htdoc
)
Problem of slash
Moderator: General Moderators
Re: Problem of slash
Code: Select all
<?php
foreach ($array as $key => $value) {
$array[$key] = ltrim('/', $value); // remove char from left side of string
$array[$key] = rtrim('/', $value); // remove char from right side of string
$array[$key] = trim('/', $value); // remove char from left & right side of string
}-
aliahsan81
- Forum Newbie
- Posts: 8
- Joined: Thu Sep 04, 2008 4:46 pm
Re: Problem of slash
Thxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Alot.Its worked