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

Other language site
ja ja
Google Translate
  • -

    シェア
  • ---

    LINEで送る
  • -

    はてなブックマーク
    ブックマーク
  • -

    pocket
  • -

    rss
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.

<?php
$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!