Created
July 5, 2019 13:21
-
-
Save tolgacibikci/250bb5648b054244fa3511b5e7537b67 to your computer and use it in GitHub Desktop.
Code Snippets
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
| function convert2_humanreadable_dateformat($date,$delimeter,$has_time) { | |
| $date_arr = array(); | |
| $date_arr_time = explode(" ",$date); | |
| $date_arr = explode($delimeter,$date_arr_time[0]); | |
| if ($has_time) { | |
| $result = $date_arr[2]."/".$date_arr[1]."/".$date_arr[0]." ".$date_arr_time[1]; | |
| } | |
| else { | |
| $result = $date_arr[2]."/".$date_arr[1]."/".$date_arr[0]; | |
| } | |
| return $result; | |
| } |
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
| function convert2_mysql_dateformat($date,$delimeter,$has_time) { | |
| $date_arr = array(); | |
| $date_arr_time = explode(" ",$date); | |
| $date_arr = explode($delimeter,$date_arr_time[0]); | |
| if ($has_time) { | |
| $result = $date_arr[2]."-".$date_arr[1]."-".$date_arr[0]." ".$date_arr_time[1]; | |
| } | |
| else { | |
| $result = $date_arr[2]."-".$date_arr[1]."-".$date_arr[0]; | |
| } | |
| return $result; | |
| } |
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
| function generate_string($length) { | |
| $char_pool = array_merge(range('a', 'z'),range('A', 'Z'),range(0,9)); | |
| $session = ""; | |
| for ($i=0; $i < $length; $i++) { | |
| $session .= $char_pool[mt_rand(0, count($char_pool) - 1)]; | |
| } | |
| return $session; | |
| } |
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
| function money_format($format, $number) { | |
| // ... Format | |
| $format = str_replace("n","",str_replace("%.","",$format)); | |
| $number_arr = explode('.', $number); | |
| if (count($number_arr) < 2) { | |
| $number_arr[1] = '00'; | |
| } | |
| $number_arr[0] = number_format($number_arr[0]); | |
| $number_arr[0] = str_replace(',','.',$number_arr[0]); | |
| $number_arr[1] = substr($number_arr[1],0,$format); | |
| return $number_arr[0].','.$number_arr[1]; | |
| } |
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 | |
| function replace_special_characters($string) { | |
| $string = str_replace("!","", $string); | |
| $string = str_replace("'","", $string); | |
| $string = str_replace("^","", $string); | |
| $string = str_replace("+","", $string); | |
| $string = str_replace("%","", $string); | |
| $string = str_replace("&","", $string); | |
| $string = str_replace("/","", $string); | |
| $string = str_replace("(","", $string); | |
| $string = str_replace(")","", $string); | |
| $string = str_replace("=","", $string); | |
| $string = str_replace("*","", $string); | |
| $string = str_replace("?","", $string); | |
| $string = str_replace("#","", $string); | |
| $string = str_replace("$","", $string); | |
| $string = str_replace("{","", $string); | |
| $string = str_replace("[","", $string); | |
| $string = str_replace("]","", $string); | |
| $string = str_replace("}","", $string); | |
| $string = str_replace(" ","-", $string); | |
| return $string; | |
| } |
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
| function string_to_url($string) { | |
| $string = str_replace("Ç","C", $string); | |
| $string = str_replace("ç","c", $string); | |
| $string = str_replace("İ","I", $string); | |
| $string = str_replace("ı","i", $string); | |
| $string = str_replace("Ğ","G", $string); | |
| $string = str_replace("ğ","g", $string); | |
| $string = str_replace("Ü","U", $string); | |
| $string = str_replace("ü","u", $string); | |
| $string = str_replace("Ö","O", $string); | |
| $string = str_replace("ö","o", $string); | |
| $string = str_replace("Ş","S", $string); | |
| $string = str_replace("ş","s", $string); | |
| $string = str_replace("!","", $string); | |
| $string = str_replace("'","", $string); | |
| $string = str_replace("^","", $string); | |
| $string = str_replace("+","", $string); | |
| $string = str_replace("%","", $string); | |
| $string = str_replace("&","", $string); | |
| $string = str_replace("/","", $string); | |
| $string = str_replace("(","", $string); | |
| $string = str_replace(")","", $string); | |
| $string = str_replace("=","", $string); | |
| $string = str_replace("*","", $string); | |
| $string = str_replace("?","", $string); | |
| $string = str_replace("#","", $string); | |
| $string = str_replace("$","", $string); | |
| $string = str_replace("{","", $string); | |
| $string = str_replace("[","", $string); | |
| $string = str_replace("]","", $string); | |
| $string = str_replace("}","", $string); | |
| $string = str_replace(".","", $string); | |
| $string = str_replace(",","", $string); | |
| $string = str_replace(" ","-", $string); | |
| $string = strtolower($string); | |
| return $string; | |
| } |
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
| function tr_2_en($string) { | |
| $string = str_replace("Ç","C", $string); | |
| $string = str_replace("ç","c", $string); | |
| $string = str_replace("İ","I", $string); | |
| $string = str_replace("ı","i", $string); | |
| $string = str_replace("Ğ","G", $string); | |
| $string = str_replace("ğ","g", $string); | |
| $string = str_replace("Ü","U", $string); | |
| $string = str_replace("ü","u", $string); | |
| $string = str_replace("Ö","O", $string); | |
| $string = str_replace("ö","o", $string); | |
| $string = str_replace("Ş","S", $string); | |
| $string = str_replace("ş","s", $string); | |
| return $string; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment