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'
|
* 'url => 'url'
|
||||||
*/
|
*/
|
||||||
function api_contactlink_to_array($txt) {
|
function api_contactlink_to_array($txt) {
|
||||||
$elm = new SimpleXMLElement($txt);
|
$match = array();
|
||||||
return array(
|
$r = preg_match_all('|<a href="([^"]*)">([^<]*)</a>|', $txt, $match);
|
||||||
'name' => $elm->__toString(),
|
if ($r && count($match)==3) {
|
||||||
'url' => $elm->attributes()['href']->__toString()
|
$res = array(
|
||||||
|
'name' => $match[2],
|
||||||
|
'url' => $match[1]
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
$res = array(
|
||||||
|
'name' => $text,
|
||||||
|
'url' => ""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue