Skip to content

Instantly share code, notes, and snippets.

View vrushank-snippets's full-sized avatar

Vrushank vrushank-snippets

View GitHub Profile
@vrushank-snippets
vrushank-snippets / CSS Tooltip
Created March 23, 2012 11:56
CSS : CSS Tooltip
a:hover { background:#ffffff; text-decoration:none;} /*BG color is a must for IE6*/
a.tooltip span {display:none; padding:2px 3px; margin-left:8px; width:130px;}
a.tooltip:hover span{display:inline; position:absolute; background:#ffffff; border:1px solid #cccccc; color:#6c6c6c;}
Easy <a class="tooltip" href="#">Tooltip<span>This is the crazy little Easy Tooltip Text.</span></a>
@vrushank-snippets
vrushank-snippets / Cross browser opacity
Created March 23, 2012 11:55
CSS : Cross browser opacity
selector {
opacity: .75; /* Standard: FF gt 1.5, Opera, Safari */
filter: alpha(opacity=75); /* IE lt 8 */
-ms-filter: "alpha(opacity=75)"; /* IE 8 */
-khtml-opacity: .75; /* Safari 1.x */
-moz-opacity: .75; /* FF lt 1.5, Netscape */
}
@vrushank-snippets
vrushank-snippets / Convert strings to slugs
Created March 23, 2012 11:03
PHP : Convert strings to slugs
function slug($str){
$str = strtolower(trim($str));
$str = preg_replace('/[^a-z0-9-]/', '-', $str);
$str = preg_replace('/-+/', "-", $str);
return $str;
}
@vrushank-snippets
vrushank-snippets / Remove URLs from string
Created March 23, 2012 11:02
PHP : Remove URLs from string
$fh = fopen("contacts.csv", "r");
while($line = fgetcsv($fh, 1000, ",")) {
echo "Contact: {$line[1]}";
}
@vrushank-snippets
vrushank-snippets / Parse CSV files
Created March 23, 2012 11:02
PHP : Parse CSV files
$fh = fopen("contacts.csv", "r");
while($line = fgetcsv($fh, 1000, ",")) {
echo "Contact: {$line[1]}";
}
@vrushank-snippets
vrushank-snippets / Search for a string in another string
Created March 23, 2012 11:00
PHP : Search for a string in another string
function contains($str, $content, $ignorecase=true){
if ($ignorecase){
$str = strtolower($str);
$content = strtolower($content);
}
return strpos($content,$str) ? true : false;
}
@vrushank-snippets
vrushank-snippets / Extract emails from a string
Created March 23, 2012 10:59
PHP : Extract emails from a string
function extract_emails($str){
// This regular expression extracts all emails from a string:
$regexp = '/([a-z0-9_\.\-])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i';
preg_match_all($regexp, $str, $m);
return isset($m[0]) ? $m[0] : array();
}
$test_string = 'This is a test string...
@vrushank-snippets
vrushank-snippets / Transform URL to hyperlinks
Created March 23, 2012 10:56
PHP : Transform URL to hyperlinks
@vrushank-snippets
vrushank-snippets / Get the text between $start and $end
Created March 23, 2012 10:54
PHP : Get the text between $start and $end
function GetBetween($content,$start,$end){
$r = explode($start, $content);
if (isset($r[1])){
$r = explode($end, $r[1]);
return $r[0];
}
return '';
}
@vrushank-snippets
vrushank-snippets / Automatically remove html tags from a string
Created March 23, 2012 10:54
PHP : Automatically remove html tags from a string
$text = strip_tags($input, "");