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
If you know that your words will be separated by commas you can do something like:
$key = 2; $string = "red,green,blue,yellow,black"; $arr = explode(",",$string); echo $arr[$key];