Showing posts with label CakePHP. Show all posts
Showing posts with label CakePHP. Show all posts

Wednesday 4 May 2016

Convert PHP, Magento, Joomla, Codeigniter, Cake PHP, Wordpress XML to JSON, XML to Array, JSON to Array

Convert PHP, Magento, Joomla, Codeigniter, Cake PHP, Wordpress XML to JSON, XML to Array, JSON to Array is very difficult task for some people. But, in PHP, believe me it’s very easy. One line of code each! Don’t believe? Just check out the code below and test it yourself!


$xml = simplexml_load_string($xmldata);
$json = json_encode($xml);
$array = json_decode($json,true);

Saturday 9 April 2016

How to get last week' date range in PHP, Codeigniter, CakePHP

$previous_week = strtotime("-1 week +1 day");
$start_week = strtotime("last sunday midnight",$previous_week);
$end_week = strtotime("next saturday",$start_week);
$start_week = date("Y-m-d",$start_week);
$end_week = date("Y-m-d",$end_week);
echo $start_week.' '.$end_week ;