The Snippets Thread
10-27-2011, 01:40 PM, (This post was last modified: 10-27-2011, 09:02 PM by Arthur.)
#5
RE: The Snippets Thread
When I saw this thread, I thought "Oh! I'll post my hex color code generator!", but obviously that would be pointless, as there already is one. So I'll post my snippet to delete all files in a directory (useful if you want to have a temp folder and it gets full of non-deleted useless files.)
PHP Code:
function empty_folder($folder){
    
$files glob("$folder/*");
    for (
$i 0$i count($files); $i++){
        
unlink($files[$i]);
    }


Function to highlight a string where $str is the string to be highlighted, $bg is whether it's the background or the text that's highlighted, and $color is what color to highlight it:
PHP Code:
function highlight($str$bg=true$color=false){
    
$type "";
    if (!
$color){
        
$color "#8B8B00";
    }
    if (
$bg){
        
$type "background-";
    }
    return 
"<span style='".$type."color:$color;'>".$str."</span>";

Reply


Messages In This Thread
The Snippets Thread - by MyDigitalpoint - 08-15-2011, 12:00 PM
RE: The Snippets Thread - by HiddenKnowledge - 10-02-2011, 11:35 PM
RE: The Snippets Thread - by MyDigitalpoint - 10-20-2011, 08:24 AM
RE: The Snippets Thread - by Zach - 10-20-2011, 09:37 AM
RE: The Snippets Thread - by Arthur - 10-27-2011, 01:40 PM
RE: The Snippets Thread - by Zach - 10-27-2011, 02:42 PM
RE: The Snippets Thread - by Arthur - 10-27-2011, 09:01 PM
RE: The Snippets Thread - by Serial Thrilla - 01-18-2012, 02:33 AM
RE: The Snippets Thread - by Arthur - 04-12-2012, 07:28 AM

Forum Jump: