I am not good in preg thingy but i found out a function called preg_split.
Let's said i have a string : "word1<>word2<>word3<>word4"
I want to split the the string and extract word 1 to word 4 without the <>
How do i do that in preg?
my code :
$extractedWord = preg_split(<pattern>,"word1<>word2<>word3<>word4");
If your trying to use preg_split()
instead of explode()
or other php function that has same results function
$extractedWord = "word1<>word2<>word3<>word4"; // values to be splitted on "<>"
$result = preg_split("/<>/",$extractedWord); // execute function to split
print_r($result);
Generated Output would be :
Array
(
[0] => word1
[1] => word2
[2] => word3
[3] => word4
)
$mystring="word1<>word2<>word3<>word4";
print_r(explode('<>',$mystring));
Regexes are for regular expressions, not static strings:
$extractedWords = explode("<>",$inputString);