I started learning RegEx and I want to take some data from a website(learning purpose only). Please help me with preg_match_all. this is what I need to get <li> <a href="/play/3614/crush-the-castle" title="Crush the Castle"><img src="/files/thumbnails/crush-the-castle-3614.jpg" alt="Crush the Castle" width="60" height="60" /></a> <h5> <a href="/play/3614/crush-the-castle" title="Crush the Castle" class="">Crush the Castle</a> </h5> <p class="plays">13,106,764 plays</p> <p class="rating">Rating: 9/10</p> </li> PHP: I need something like: link:/play/3614/crush-the-castle title:Crush the Castle img:/files/thumbnails/crush-the-castle-3614.jpg alt:Crush the Castle and sizes.. Please explain what you do in details.. Thanks
Hi, I would suggest to search thread for similar queries before posting.. Just few minutes back similar query was answered.. have a look at following thread.. http://forums.digitalpoint.com/showthread.php?t=1539462
Get Links href="([^"]+)" All others, similar. Just change href to title, img, etc. Try this in PHP Regular Expression Tester
Simple pattern $pattern = "/<a href="([^"]+)" title="([^"]+)"><img src="([^"]+)" alt="([^"]+)" width="([^"]+)" height="([^"]+)" \/>/"; PHP: outputs Array ( [0] => <a href="/play/3614/crush-the-castle" title="Crush the Castle"><img src="/files/thumbnails/crush-the-castle-3614.jpg" alt="Crush the Castle" width="60" height="60" /> [1] => /play/3614/crush-the-castle [2] => Crush the Castle [3] => /files/thumbnails/crush-the-castle-3614.jpg [4] => Crush the Castle [5] => 60 [6] => 60 ) Code (markup):