I was recently tasked to write a system that involves a lot of XML transfer between two or more systems, in some cases the XML needs to be appended and then transfered, I struggled for a bit with the appending but soon bumped into a function that did the trick… If you have an extender class, just simply copy and paste…
<?php
class SimpleXMLExtended extends SimpleXMLElement{
public function Attribute($name){
/**
* manipulate xml attributes
*/
foreach($this->Attributes() as $key=>$val){
/**
* attribute found, return the value
*/
if( strcasecmp($key,$name) == 0 ){
return (string)$val;
}
}
}
}
?>
Hope you find it useful…
I have been working on a cron to update payment cycles on a payment management system -
I have had to do this before, when I had to get week end and start dates - with the help of google I had a sample script which was about 100 lines long - Today I had to do the same but I lost my script with my old machine - after cracking my head for about 20 minutes on how im going to get this rite I came up with nifty piece of —
<?php
$this_year = date(”Y”);
$num_weeks = date(”W”, mktime(0,0,0,12,31,$this_year));
for ($x=1;$x<=$num_weeks;$x++){
$week_number = ”;
(strlen($x) == 1) ? $week_number = “0$x” : $week_number = $x;
$week_start = date(’Y-m-d’, strtotime(”{$this_year}W{$week_number}”));
$week_end = date(’Y-m-d’, strtotime(”{$this_year}W{$week_number}7″));
echo “$x - $week_start To $week_end
“;
}
?>
Hope y’all find it useful