Question

I am new to PHP regular expression syntax. Using the following two lines, I was able to phrase a website depending on the following characters : newline

$html = @file_get_contents("http://news.yahoo.com");
$webwords = preg_split("/[:'\n\"]+/", $html);

Above code will only allow me to phrase a website depending on individual characters. Can you please tell me how I can parse a website with word phrases ? For example, above individual characters alone with the word image_17

$webwords = preg_split("/[:'\n\"]+ | (image_17) /", $html);     ??
Was it helpful?

Solution

Maybe do you need something similar?

$html = 'xxx:yyyimage_17aaa:9999';
$webwords = preg_split("/([:'\n\"]+|image_17)/", $html);
print_r($webwords);

And the output:

Array
(
    [0] => xxx
    [1] => yyy
    [2] => aaa
    [3] => 9999
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top