Test when there are no properties

I've create a script that will delete all user properties for a particular individual. I'm able to use an api call to get the users' properties from the xml. And I'm using a delete api to remove each property. I would like to be able to test when there are no more properties left and then output a message accordingly. Inside the for loop is where each property is found. Any help is certainly appreciated.Below is the code:\[code\]<?php$user_id="[email protected]";$url=('http://user:[email protected]/@api/users/[email protected]/properties');$xmlString=file_get_contents($url);$delete = "http://user:[email protected]/@api/DELETE:users/$user_id/properties/%s";$xml = new SimpleXMLElement($xmlString); function curl_fetch($url,$username,$password,$method='DELETE'){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // returns output as a string instead of echoing it curl_setopt($ch,CURLOPT_USERPWD,"$username:$password"); // if your server requires basic auth do this return curl_exec($ch);}foreach($xml->property as $property) { $name = $property['name']; // the name is stored in the attribute curl_fetch(sprintf($delete, $name),'user','12345');}?>\[/code\]
 
Back
Top