note 81922 modified in ref.simplexml by danbrown
| From: | danbrown@php.net | Date: | Mon, 18 May 2009 01:14:03 +0000 |
| Subject: | note 81922 modified in ref.simplexml by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155495@lists.php.net to get a copy of this message | ||
implode() can't be used for simplexml's array but foreach() does the thing, make new
implode function with foreach() will resolve this problem. use strval() to reset SimpleXMLElement
object to a simple string variable.
<?php
function implode2($glue="", $var){
if ($var){
foreach ($var as $value){
$array[]=strval($value);
}
return implode($glue, $array);
}
else return false;
}
?>
--was--
implode() can't be used for simplexml's array but foreach() does the thing, make new
implode function with foreach() will resolve this problem. use strval() to reset SimpleXMLElement
object to a simple string variable.
function simplexml_implode ($glue="", $var){
if ($var){
foreach ($var as $value){
$array[]=strval($value);
}
} return implode($glue, $array);
else return false;
}
http://php.net/manual/en/ref.simplexml.php