Tuesday, 15 May 2012

php - Extract certain string format -


I'm not good at preg thingy, but I found a function called preg_split.

Let's say I have the string: "word1 4 < P> I want to split the string and without the word 4 want to remove word 4 in & lt; & Gt;

How do I do it in the preggae?

My code: $ extractedWord = preg_split (& lt; pattern & gt ;, 'wORD1 & lt;> WORD2 & lt;> word3 & Lt;> word4 ");

If you use preg_split () instead Trying Explosion () or other php function whose same result is function

  $ extractedWord = "word1" and <; Word2 & lt; & Gt; Word 3 & lt; & Gt; Word4 "; // values" & lt; & Gt; $ Result = preg_split ("/>   

The generated output will be:

  Array ([0] => 1 [1] => 2 [2] = & Gt; word 3 [3] = & gt; word4)    

No comments:

Post a Comment