Ask the php cool man to write a judgment post. at last, the keyword "how to judge the first appearance" in php is "& lt; strong & gt;" is edited by music_vip_2009 from 2014-01-0323: 21: 20; if the first keyword is not added with the & lt; a & gt; tag, the link is added when the second keyword appears! Example: If the first keyword is & lt; strong & gt; Baidu & lt; strong & ask the php cool to write a judgment
This post was last edited by music_vip_2009 at 23:21:20, January 3 ,.
How can I use php to determine the keyword that appears for the first time?
If the first keyword is not tagged, the link is added when the second keyword appears!
Example: If the first keyword isBaidu
. Then this tag is filtered out, and then added when the word "Baidu" appears for the second time.
I don't know what I mean. if you don't understand php, please reply to me! The younger brother has no points. thank you for your help!
Share: More
------ Solution --------------------
$ Html = <
Text 1
Text 2
Text 3
Text 4
Text 5
EOT;
Preg_match_all ('@(.*?) <\/Strong> @ I ', $ html, $ match );
Foreach ($ match [0] as $ k => $ row ){
If ($ k = 0 ){
$ Result = $ row;
} Else {
$ Result. = ''. $ row .'';
}
}
Echo $ result;