Re: remove from a string
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: remove from a string

From: Ken Robinson <kenrbnsn@rbnsn.com>
Date: Fri Aug 26 2005 - 00:17:01 CEST

werdna.si...@gmail.com wrote:
> Is there a function in PHP that will remove a blob from inside a
> string. Similar to the substr() function, but instead of giving me the
> string I want it to remove the string.
>
> For example, I have the string "john goes running" I want to be able
> to tell it to remove 5 characters starting at position 4, which would
> get me "john running"

You could combine str_replace and substr:

$str = 'john goes running';
echo str_replace(substr($str,4,5),'',$str);

Ken
Received on Mon Oct 24 02:09:33 2005