addAttribute()

It adds an attribute to the SimpleXML element

Example

<?php
$xmlObj = simplexml_load_file(“test.xml”);
$xmlObj->client[0]->addAttribute(“ver”, “5”);
foreach($xmlObj->client[0]->attributes() as $a => $b) {
echo $a,’=”‘,$b,””</br>”;
}
?>

Output

ver=”5″

XML

<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<web>
<server>Apache</server>
<lan>PHP</lan>
<client>Javascript</client>
</web>


wordwrap()

It wraps a string into new lines when it reaches a specific length.

Example

<?php
echo wordwrap(“It wraps a string into new lines when it reaches a specific length”,5);
?>

Output

It wraps a string into new lines when it reaches a specific length