i have html code i need to receive name +price how can i build Regular expression with php: <a href="/p/doogee-titans2-dg700-android-4-4-quad-core-wcdma-bar-phone-w-4-5-ogs-8gb-rom-gps-otg-presale-852367526" title="DOOGEE TITANS2 DG700 Android 5.0 Quad-Core WCDMA Bar Phone w/ 4.5" OGS, 8GB ROM, GPS, OTG">DOOGEE TITANS2 DG700 Android 5.0 Quad-Core WCDMA Bar Phone w/ 4.5" OGS, 8GB ROM, GPS, OTG</a> HTML: <p class="price"> US$103.46 </p> HTML: how can i use preg_match_all() ?
scan for lines apply for example: if(preg_match("/\/p\//i", $line)) { and also if(preg_match("/class=\"price\"/i", $line)) { then you can use explode() to get the content of a href or the content inside <p>
For scraping HTML code, it is wise to not use regex as the HTML is more complex than that. You could use DOM or XPATH for this
Malformed HTML don't always work with XPATH. This is a great library. I've never seen in break and ran some nasty crap thru it. http://simplehtmldom.sourceforge.net/