PHP - get certain word from string
问题 If i have a string like this: $myString = "input/name/something"; How can i get the name to be echoed? Every string looks like that except that name and something could be different. 回答1: so the only thing you know is that : it starts after input it separated with forward slashes. > $strArray = explode('/',$myString); $name = $strArray[1]; $something = $strArray[2]; 回答2: If you only need "name" list(, $name, ) = explode('/', $myString); echo "name is '$name'"; If you want all, then list(