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

Other language site
No available translations found
Google Translate
  • ---

    Send by LINE
  • -

  • -

  • -

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.

SNS also distributes articles.
Leave a Reply


If you like this article, share it!