Skip to content
Advertisement

Website Scraping from DoMDocument using php

I have a php code that could extract the categories and display them. However, I still can’t extract the numbers that goes along with it too(without the bracket). Need to be separated between the categories and number(not extract together). Maybe do another for loop using Regex, etc…

This is the code:

JavaScript

Is there any way I could do that? Thanks!

This is my desired output:

JavaScript

Advertisement

Answer

Just add the other sibling as well. Example:

JavaScript

EDIT: Just use str_replace for that simple purpose of removing that parenthesis.

Sidenote: Always put the UTF-8 Encoding on your PHP file.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement