Hi, I am scraping a site to get its all url inside a div. I got multiple links from that div. preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $table, $match); print_r($match[0]); Code (markup): I got all links in an array. The print_r function contains the data like following. (it don't display in my page but in source code) Array ( [0] => https://aaaa.com/wp-content/themes/jnews/assets/img/jeg-empty.png [1] => https://aaaa.com/wp-content/uploads/2020/10/NF-100-3-750x394.jpg [2] => https://aaaa.com/wp-content/uploads/2020/10/NF-100-3-750x394.jpg [3] => https://aaaa.com/wp-content/uploads/2020/10/NF-100-3-300x158.jpg [4] => https://aaaa.com/wp-content/uploads/2020/10/NF-100-3-1024x538.jpg [5] => https://aaaa.com/wp-content/uploads/2020/10/NF-100-3-768x403.jpg ) Code (markup): I need only the second link in variable so that I can use it in my php code. But how can I will take the second link from the array? Please help.
Why the regex crap when you could just load it into DOMDocument and walk it? Or are they in there as plaintext and not actual href/src?