Thread: A few easy functions

Results 1 to 6 of 6
  1. #1 A few easy functions 
    Banned

    Join Date
    Nov 2014
    Posts
    611
    Thanks given
    180
    Thanks received
    156
    Rep Power
    0
    Code:
    	function prev($fallback) {
    
    		$previous = "javascript:history.go(-1)";
    		if(isset($_SERVER['HTTP_REFERER'])) {
    		    return $previous;
    		} else {
    			return $fallback;
    		}
    
    	}
    Usage: prev("index.php");
    Explanation: Sees if there is a previous page value set, if so, return link to previous page, otherwise returns fallback link

    Code:
    	function euro($amount) {
    
    		$formatter = new NumberFormatter('nl_NL',  NumberFormatter::CURRENCY);
    		return $formatter->formatCurrency($amount, 'EUR');
    
    	}
    Usage: euro(100000);
    Explanation: Returns euro value (€ 100.000,00)

    Code:
    	function fileExtension($file) {
    
    		$ext = pathinfo($file, PATHINFO_EXTENSION);
    
    		return $ext;
    
    	}
    Usage: fileExtension("image.png");
    Explanation: Returns the extension of any file with a set extension

    Code:
    	function msg($key, $msg) {
    
    		switch($key) {
    
    			case "s":
    				$icon = "check";
    				$smsg = "Success";
    				$flag = "success";
    				break;
    
    			case "w":
    				$icon = "exclamation-triangle";
    				$smsg = "Warning";
    				$flag = "warning";
    				break;
    
    			case "d":
    				$icon = "times";
    				$smsg = "Error:";
    				$flag = "danger";
    				break;
    
    			case "i":
    				$icon = "info";
    				$smsg = "Information:";
    				$flag = "info";
    				break;
    
    			default:
    				$icon = "times";
    				$flag = "danger";
    				$smsg = "Unknown error:";
    				break;
    
    		}
    
    		echo '<div class="alert alert-'.$flag.' text-center"><b><i class="fa fa-'.$icon.'"></i> '.$smsg.'</b><br />'.$msg.'</div>';
    
    	}
    Usage: Switches between alerts tag, error message, and icon: msg("tag", "message");
    Explanation: Extremely convenient and easy to use when you wish to have simple alerts like these:
    Requirement: Bootstrap style library and FontAwesome

    Attached image

    If you like these, i'll release more
    I know they're easy to write, but incredibly convenient
    Reply With Quote  
     

  2. Thankful users:


  3. #2  
    Registered Member
    excl150's Avatar
    Join Date
    Jul 2014
    Posts
    123
    Thanks given
    46
    Thanks received
    30
    Rep Power
    97
    nice release, might use =)
    Reply With Quote  
     

  4. #3  
    Banned

    Join Date
    Nov 2014
    Posts
    611
    Thanks given
    180
    Thanks received
    156
    Rep Power
    0
    Bump
    Reply With Quote  
     

  5. #4  
    Registered Member Limp's Avatar
    Join Date
    Apr 2016
    Posts
    57
    Thanks given
    12
    Thanks received
    5
    Rep Power
    23
    Looks good
    Attached image
    Reply With Quote  
     

  6. #5  
    Banned

    Join Date
    Nov 2014
    Posts
    611
    Thanks given
    180
    Thanks received
    156
    Rep Power
    0
    I'll add more if ya'll like it
    Reply With Quote  
     

  7. #6  
    Banned

    Join Date
    Nov 2014
    Posts
    611
    Thanks given
    180
    Thanks received
    156
    Rep Power
    0
    Bump
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [Request] A few easy models for Borderscape
    By TheRedArmy in forum Models
    Replies: 6
    Last Post: 01-07-2012, 08:23 AM
  2. Paying for few easy things done FOR PI --- >
    By Aaron Project in forum Requests
    Replies: 1
    Last Post: 05-27-2011, 01:33 PM
  3. Few easy questions.
    By Cody_ in forum Help
    Replies: 4
    Last Post: 01-27-2011, 05:39 AM
  4. a few easy bucks
    By Virtual in forum Chat
    Replies: 31
    Last Post: 12-04-2010, 06:21 PM
  5. A few easy questions
    By FuglyNerd in forum Help
    Replies: 9
    Last Post: 11-21-2009, 12:09 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •