Icon

Just Some Shit I Thought And Wrote.

Appending XML To Existing XML Document (PHP)

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…

Getting Week Start And End Date Using PHP

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

Kohjinsha Netbook Concept

Dual View Netbook

This would make a pretty cool toy. Read More

RSS Photography

  • No turning.....back February 6, 2012
    Pride can ruin lives, greed can destroy homes, hate can orphan those relying on others for guidance and support. (A rushed shot through a moving car window somewhere in Jo'Burg)
    Sthe Ngcobo
  • daisy leaf February 6, 2012
    paulscott56
  • (untitled) February 6, 2012
    lerato caphus
  • Dismantle February 6, 2012
    Hello, I have no clue what this is or where this was taken. I am yet to decide if I prefer it this way up or up-side-down. 1ove, abstract.
    lebogang nkoane
  • The Fist February 6, 2012
    twiggle stix