satishgaudo.com

Understanding technology

Archive for November, 2011

Php:trim a string without cutting the word

function neat_trim($str, $n, $delim=’…’) { $len = strlen($str); if ($len > $n) { preg_match(’/(.{’ . $n . ‘}.*?)\b/’, $str, $matches); return rtrim($matches[1]) . $delim; } else { return $str; [...]

19 November 2011 at 13:13 - Comments

Php:get valid url

function formatUrl($sDispTitle){ $sDispTitle = str_replace(’-',”,$sDispTitle); $sDispTitle = str_replace(’ ‘,’-',$sDispTitle); $sDispTitle = str_replace(’,',’-',$sDispTitle); $sDispTitle = str_replace(’&’,”,$sDispTitle); $sDispTitle = str_replace(’/',’-',$sDispTitle); $sDispTitle = str_replace(’.',”,$sDispTitle); $sDispTitle = str_replace(’?',”,$sDispTitle); $sDispTitle = str_replace("’",”,$sDispTitle); $sDispTitle = str_replace("!",”,$sDispTitle); $sDispTitle = str_replace(’"’,”,$sDispTitle); $sDispTitle = str_replace(’%',”,$sDispTitle); $sDispTitle = str_replace(’#',”,$sDispTitle); return $sDispTitle; }

19 November 2011 at 13:11 - Comments

PHP:check if valid email using regular expression

function isValidEmail($email){ return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email); }

19 November 2011 at 13:08 - Comments

Regular expression to replace multiple white spaces with single -

$sTitle="test test123";   $sTitle = preg_replace("’\s+’", ‘-’, $sTitle);   print $sTitle;   output:test-test123

19 November 2011 at 12:04 - Comments

PHP: Uploaded media file type validation

function typevalidation($uploadfiletype,$mediatype,$tmpfilename="") { if ($tmpfilename) { $sfiletype = shell_exec("mimetype -bi $tmpfilename"); //echo "In".$sfiletype; $typearr=explode("/",$sfiletype); $filetype=$typearr[0]; $fileext=$typearr[1]; }   if($uploadfiletype==’thumb’) { if($filetype!=’image’) { $errmsg="errormessage1"; } else{ $errmsg="ok"; } } else if($uploadfiletype==’media’) { if($mediatype=="image") { if($filetype!=’image’) { $errmsg="errormessage2"; } else {$errmsg="ok"; } } else if($mediatype=="video") { if($filetype!=’video’) { $errmsg="errormessage3"; } elseif(strpos($fileext,"flv")===false) { $errmsg="errormessage4"; } else {$errmsg="ok"; } } } return $errmsg; }

19 November 2011 at 11:57 - Comments

YouTube Trends Dashboard

Want to know wants trending now on youtube just check YouTube Trends Dashboard

11 November 2011 at 00:39 - Comments

Real-Time Insights Finder | Think Insights with Google

A Google developed tool that hubs up all the great complimentary Google tools to understand the key target consumer, where and how they spend time. Essential for media planning! Google Insights

11 November 2011 at 00:34 - Comments

Google Maps JavaScript API v3 Example

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <style type="text/css"> html { [...]

2 November 2011 at 16:09 - Comments