Created
May 26, 2013 15:26
-
-
Save INDIAN2020/5653110 to your computer and use it in GitHub Desktop.
php: helperfunctions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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