PHP DOM parser function
$10-30 USD
Płatność przy odbiorze
I need a PHP function which can parse HTML string, search for specific selector path, and return the content of all matched elements. The function will be called parse() and will accept two arguments, as defined: function parse(&$html, $selector). Return value will be array of found code blocks.
The $html parameter will be a complete webpage HTML string. Remember it may be not-perfectly-valid HTML.
The $selector parameter will be a string of space-separated selectors which create full path to one or more subsections of the $html string. For example, $selector can be as simple as "#myelement", which matches everything inside <tag id="myelement">..</tag>
Similarly the selector can be as simple as ".className", which will match all tags with className in "class" attribute, so even <div class="otherClassName className">...</div>
Also the $selector can be more complicated expression, like "[login to view URL] [login to view URL]"
The above mentioned example selector will match the first and third block in this HTML:
<div class="className1 className2 classNameX"><span class=cls>xxx</span></div>
<div class="className2 className1 classNameX"><span>yyy</span></div>
<div class="classNameX className2 className1"><span class=cls>z<b>z</b>z</span></div>
Return value will be an array with all the subsections of the $html string as matched by the $selector. Pure HTML returned, no objects. So for our example example, with the above mentioned selector and html code, return value will be this array: ["xxx", "z<b>z</b>z"]
You are not allowed to use any external PHP libraries, only use PHP's native functions.
Numer ID Projektu: #11509192
O projekcie
5 freelancerów złożyło ofertę za $31 w tym projekcie
I have 6 years experience as web developer I can provide you the solution we can discuss more details over chat.