PHP: All File Delete with Extension


 public function delete_all_file($dir=NULL,$ext=NULL){
        array_map('unlink', glob(".$dir."/*.".$ext."));
    }

PHP: Array to CSV Converter

           function exportCSV($data=array()){
		$file = fopen("reports.csv","w");
		foreach ($data as $line){
		  fputcsv($file,$line);
		  }
		fclose($file);
		} 

PHP: Get Location

    function getLocationName(){
	$tz = new DateTimeZone("Asia/Dhaka");
	$loc=$tz->getLocation();
	$geocode=file_get_contents('http://maps.googleapis.com/maps/api/geocode/
        json?latlng='.$loc['latitude'].','.$loc['longitude'].'&sensor=false');
	$output= json_decode($geocode);
	$output->results[0]->formatted_address;
	}

PHP: Date Format Change

function DateChangeFormat($str,$old_format,$new_format){
        $date=DateTime::createFromFormat($old_format,$str);
        return $date->format($new_format);
        }

PHP: Array Search By Key & Value

	function search($array, $key, $value){
        $results = array();
        if (is_array($array)){
            if (isset($array[$key]) && $array[$key] == $value){
                $results[] = $array;
                }
            foreach ($array as $subarray){
                $results = array_merge($results, $this->search($subarray, $key, $value));
                }
            }
        return $results;
        }