Send by LINE
B! Bookmarks in Hate-bu
Bookmarks in Pocket
RSS feeds

php: Easy !! Delete specified character string from character string

Other language site
No available translations found
Google Translate
php logo

This is a method of deleting arbitrary character string from character string with php. Use str_replace().

To delete an arbitrary character string from a character string, use str_replace(). str_replace() is a string substitution function.

$str1 = "aaabbbcccdddeeeccc";
$str2 = "ccc";
$result = str_replace($str2, '', $str1);
echo $result;

Delete "ccc" from the character string. The result is "aaabbbdddeee".

PHP documentation of str_replace() is here.

Leave a Reply