Didn't work. I got the innerHtml instead of the href: preg_match_all('#<a[^>]*class="g-asm"[^>]*>(.+?)</a>#is', $contents_of_page, $classhref, PREG_SET_ORDER); foreach ($classhref as $gasmhref) { echo "Grab: ". $gasmhref[1] ."<br/>"; } PHP:
LOL, that didn't search the href... I thought you want to learn it yourself so I explained the previous regex. And well, we need to know which come first, the class attribute or href attribute before I can help you...
Here: <a class="g-asm" href="http://something.com/ws/somethingISAPI.dll?ViewItem&ssPageName=STRK:MESOX:IT&item=260447933484" id="ttl_260447933484">something</a> Code (markup): I would like to know both the full url and then the item # only.
Here preg_match_all('#<a[^>]*class="g-asm"[^>]*href="(.+?)"[^>]*>(.+?)</a>#is', $contents_of_page, $classgasm, PREG_SET_ORDER); PHP:
WHen I do print it works fine. But the following: preg_match_all('#<a[^>]*class="g-asm"[^>]*href="(.+?)"[^>]*>(.+?)</a>#is', $contents_of_page, $href, PREG_SET_ORDER); //print_r($href); foreach ($href as $classhref) { echo "Grab: ". $href[0] ."<br/>"; } PHP: Gives:
LOL.. That because you tried to echo the array... in above code, it should be this... foreach ($href as $classhref) { echo "Grab: ". $classhref[0] ."<br/>"; echo "URL: ". $classhref[1] ."<br/>"; echo "Text: ". $classhref[2] ."<br/>"; } PHP: But well, you must consistent with your code, in previous code, you pass $classxxx to the preg, but now you reverse it...
how do you put each tag in an array? I'm looking at a source and everything in the original page is disorganized. I was thinking maybe I can grab the tags using regex and put \n at the end to sort it out. But I'm not sure how the regex works.