Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. <?php
  2. if (!function_exists('UrlToUsername')) {
  3. function UrlToUsername($url,$type)
  4. {
  5. $removeurl = parse_url($url, PHP_URL_PATH);
  6. switch(true){
  7. case (($type=="facebook") || ($type=="twitter") || ($type=="instagram")):
  8. $username = str_replace('/','',$removeurl);
  9. return $username;
  10. break;
  11. case (($type=="youtube")):
  12. $uri_segments = explode('/', $removeurl);
  13. $username = $uri_segments[2];
  14. return $username;
  15. break;
  16. default:
  17. return "no type selected";
  18. }
  19. }
  20. }
  21.  
  22. function get_youtube_video_ID($youtube_video_url) {
  23.  
  24. // Checks if it matches a pattern and returns the value
  25. if (preg_match($pattern, $youtube_video_url, $match)) {
  26. return $match[1];
  27. }
  28.  
  29. // if no match return false.
  30. return false;
  31. }
  32.  
  33. if(!function_exists('rupiah')){
  34. function rupiah($angka){
  35. return number_format($angka,0,',','.');
  36. }
  37. }
  38.  
  39. if(!function_exists('json_true')){
  40. function json_true($data){
  41. $json_data = array(
  42. 'result' => TRUE,
  43. 'data' => $data
  44. );
  45. print json_encode($json_data);
  46. }
  47. }
  48.  
  49. if(!function_exists('json_false')){
  50. function json_false($message,$form_error,$redirect){
  51. $data = array(
  52. 'result' => FALSE,
  53. 'message' => $message,
  54. 'form_error' => $form_error,
  55. 'redirect' => $redirect
  56. );
  57. print json_encode($data);
  58. }
  59. }
  60.  
  61. if(!function_exists('dp')){
  62. function dp($text){
  63. echo "<pre>".print_r($text,TRUE)."</pre>";
  64. die();
  65. }
  66. }
  67.  
  68. if(!function_exists('numbercolor')){
  69. function numbercolor($number){
  70. if($number=="" || $number == 0){
  71. return "<span style='color:black;'>".$number."</span>";
  72. }else if($number>0){
  73. return "<span style='color:green;'>".$number."</span>";
  74. }else if($number<0){
  75. return "<span style='color:red;'>".$number."</span>";
  76. }
  77. }
  78. }
  79.  
  80. if(!function_exists('removeRupiah')){
  81. function removeRupiah($text){
  82. $text = str_replace(".", "", $text);
  83. return $text;
  84. }
  85. }
  86.  
  87. if(!function_exists('switchNumber')){
  88. function switchNumber($text){
  89. if($text<0){
  90. $text = abs($text);
  91. }else if($text>0){
  92. $text = "-".$text;
  93. }
  94. return $text;
  95. }
  96. }
  97.  
  98. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement