Question

I'm loading an rss feed that you can find here. I want to read the item->description. My code for that is:

$content = file_get_contents('http://www.volley-avf.be/rss/rangschikking_rss.php?reeks=D%201%20P');
$x = new SimpleXmlElement($content);


foreach($x->channel->item as $entry) {
    var_dump((string)$entry->description);
}

Now I would like to have the names of the teams. So after 1. and before the first number, I need the text. And that every time after the <br>. Can somebody help me start this regex? Because I don't know how to start on this.

UPDATE:
I've now have the following

array (size=13)
   0 => string '1. V.C . Kasterlee 12 - 8 1 - 3 - 0 - 28 - 14 -  - 26' (length=53)
   1 => string '2. Arvoc Arendonk 1 12 - 6 2 - 2 - 2 - 28 - 18 -  - 24' (length=54)
   2 => string '3. Spinley Dessel 13 - 6 2 - 3 - 2 - 29 - 23 -  - 24' (length=52)
   3 => string '4. Gea Happel V.C. Amigos St.-Antonius 3 12 - 6 1 - 3 - 2 - 27 - 19 -  - 22' (length=75)
Was it helpful?

Solution

With the description CDATA as the $input, you can use:

preg_match_all("/[0-9]+\.\s([a-zA-Z\s\.]+[0-9]*)\s[0-9]+/", $input, $output_array);

EDITTED: Now it will correctly detect numbers in team names

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top