Delete particular word from string

后端 未结 6 1382
名媛妹妹
名媛妹妹 2021-02-18 20:02

I\'m extracting twitter user\'s profile image through JSON. For this my code is:

$x->profile_image_url

that returns the url of the profile i

相关标签:
6条回答
  • 2021-02-18 20:32
    string erase(subscript, count)
        {
         string place="New York";
         place erase(0,2)
      }
    
    0 讨论(0)
  • 2021-02-18 20:33
    $s = 'Posted On jan 3rd By Some Dude';
    
    
    echo strstr($s, 'By', true);
    

    This is to remove particular string from a string.

    The result will be like this

     'Posted On jan 3rd'
    
    0 讨论(0)
  • 2021-02-18 20:34

    Php str_replace.

    str_replace('_normal', '', $var)
    

    What this does is to replace '_normal' with '' (nothing) in the variable $var. Or take a look at preg_replace if you need the power of regular expressions.

    0 讨论(0)
  • 2021-02-18 20:39

    The str_ireplace() function does the same job but ignoring the case

    like the following

    <?php
    echo str_ireplace("World","Peter","Hello world!");
    ?>
    

    output : Hello Peter!

    for more example you can see

    0 讨论(0)
  • 2021-02-18 20:41

    The str_replace() function replaces some characters with some other characters in a string.

    try something like this:

    $x->str_replace("_normal","",$x)
    
    0 讨论(0)
  • 2021-02-18 20:42

    Multi replace

    $a = array('one','two','three');
    $var = "one_1 two_2 three_3";
    str_replace($a, '',$var);
    
    0 讨论(0)
提交回复
热议问题