I have a question for those who know PHP. How can I divide a variable into several variables depending on the number of words that a variable carries? Let mi explain with an example.I have a variable $text = "one two three"; and I want to split this variable into three variables because the variable carries three words: $text1= "one"; $text2 = "two"; $text3 = "three"; But for example, if the variable were this: $text = "one two"; I would like the splitting to be: $text1= "one"; $text2 = "two";
Any ideas will be greatly appreciated.
Easiest and probably better way would be to use an array
$text = "one two three"; $spilt = explode(" ", $text);
That create an array, so $split[0] = "one" $split[1] = "two" $split[2] = "three"