PHP: equivalent of MySQL's function SUBSTRING_INDEX ?

前端 未结 5 486
南方客
南方客 2021-01-18 01:20

I love the SUBSTRING_INDEX function in MySQL, especially because you can use negative indexes to start searching from the right side of the string.

Is there an equiv

5条回答
  •  北海茫月
    2021-01-18 01:41

    If you need equivalent only for SUBSTRING_INDEX(str, delim, 1), you can use:

    list($str,) = explode($delim, $str);
    

提交回复
热议问题