Find the exact word position in string

后端 未结 5 1240
一个人的身影
一个人的身影 2020-12-22 15:28

Let\'s say I have a string.

$string = red,green,blue,yellow,black;

Now I have a variable which is the position of the word I am searching f

5条回答
  •  悲哀的现实
    2020-12-22 16:22

    This works by splitting a sentence into words based on word boundaries (Spaces, commas, periods, etc). It's more flexible than explode(), unless you are only working with comma delimited strings.

    For example, if str = 'Hello, my name is dog. How are you?', and $key = 5, You would get 'How'.

提交回复
热议问题