API: use regex instead of SimpleXMLElement
It's easier with exotic chars. And the editor replaced all leading spaces with tabs.
This commit is contained in:
parent
ce2f765d28
commit
18bd7f5eb7
1 changed files with 40 additions and 31 deletions
|
@ -2294,11 +2294,20 @@
|
|||
* 'url => 'url'
|
||||
*/
|
||||
function api_contactlink_to_array($txt) {
|
||||
$elm = new SimpleXMLElement($txt);
|
||||
return array(
|
||||
'name' => $elm->__toString(),
|
||||
'url' => $elm->attributes()['href']->__toString()
|
||||
$match = array();
|
||||
$r = preg_match_all('|<a href="([^"]*)">([^<]*)</a>|', $txt, $match);
|
||||
if ($r && count($match)==3) {
|
||||
$res = array(
|
||||
'name' => $match[2],
|
||||
'url' => $match[1]
|
||||
);
|
||||
} else {
|
||||
$res = array(
|
||||
'name' => $text,
|
||||
'url' => ""
|
||||
);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue