Problem of slash

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aliahsan81
Forum Newbie
Posts: 8
Joined: Thu Sep 04, 2008 4:46 pm

Problem of slash

Post by aliahsan81 »

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
)
ahowell
Forum Newbie
Posts: 17
Joined: Mon Sep 01, 2008 9:18 pm

Re: Problem of slash

Post by ahowell »

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

Post by aliahsan81 »

Thxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Alot.Its worked
Post Reply