Search code examples
phppathdnswords

Delete specific words from path php


How to delete specific words From Paths?

i have path:

/home/domains/www.mydomain.com/cdn/img/users/135/1341143/big_a514e41ba2187ffda494714e5a4e521f.jpg 

but i need

/www.mydomain.com/cdn/img/users/135/1341143/big_a514e41ba2187ffda494714e5a4e521f.jpg

How to make it?


Solution

  • Why don't you use simple str_replace()

    $string ='/home/domains/www.mydomain.com/cdn/img/users/135/1341143/big_a514e41ba2187ffda494714e5a4e521f.jpg';
    
       $newString = str_rplace('/home/domains','',$string);
    
       echo $newString;