PHP String Manipulation: Extract hrefs

You can use PHPs DOMDocument library to parse XML and/or HTML. Something like the following should do the trick, to get the href attribute from a string of HTML. $html=”<h1>Doctors</h1> <a title=”C – G” href=”https://stackoverflow.com/questions/4702987/linkl.html”>C – G</a> <a title=”G – K” href=”link2.html”>G – K</a> <a title=”K – M” href=”link3.html”>K – M</a>”; $hrefs = array(); $dom … Read more

href=”tel:” and mobile numbers

When dialing a number within the country you are in, you still need to dial the national trunk number before the rest of the number. For example, in Australia one would dial: 0 – trunk prefix 2 – Area code for New South Wales 6555 – STD code for a specific telephone exchange 1234 – … Read more

html links not working (using base href)

You have to quote attribute values with ” (QUOTATION MARK) or ‘ (APOSTROPHE), not “ (LEFT DOUBLE QUOTATION MARK) and ” (RIGHT DOUBLE QUOTATION MARK). This type of error is typically caused by writing code using a word processor (such as Microsoft Word or Apple Pages) with automatic replacement of quotes with typographic quotes (aka … Read more

Wrong extraction of .attr(“href”) in IE7 vs all other browsers?

It’s certainly not a bug in jQuery but instead browsers’ inconsistent implementations of .getAttribute(‘href’) – I suggest using just .get(0).href for consistency. Seems like you can access the attribute text in IE and Mozilla using .get(0).getAttribute(‘href’, 2) if you don’t want the absolute URI. Note however this won’t work in Opera and I haven’t tested … Read more