Skip to content

Instantly share code, notes, and snippets.

@INDIAN2020
Created May 26, 2013 15:26
Show Gist options
  • Select an option

  • Save INDIAN2020/5653110 to your computer and use it in GitHub Desktop.

Select an option

Save INDIAN2020/5653110 to your computer and use it in GitHub Desktop.
php: helperfunctions
<?php
class HelperFunctions
{
/**
* This function is responsible to convert % to double
* @param integer $a
* @return double
*/
public static function isPercentage($a){
if(preg_match('/%/',$a)){
$e=explode('%', $a);
return $e[0]/100;
}else{
return $a;
}
}
/**
* This function to var_dump replica
* @param array $value
* @return array
*/
public static function dump($value){
$out = "<pre>";
$out.= var_dump($value);
$out.= "</pre>";
return $out;
}
/**
* This function responsible to rid of whitespaces and replace with dash
* @param string $string
* @return string
*/
public static function fetch_value($string){
$string = trim($string);
$string = mysql_real_escape_string($string);
$string = stripslashes($string);
$string = preg_replace('/[ _]+/', '-', $string);
return $string;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment