Wednesday, 25 June 2014

PHP number format 4 digits [duplicate]

Method I

echo str_pad( "3", 4, "0", STR_PAD_LEFT );
Input $s_number = "3"; Output: 0003

Method II

$s_number = '12';
printf("%04d", $s_number);
Input $s_number = "12"; Output: 0012

Tuesday, 24 June 2014

How to get Enum Values in Mysql?


function get_enum($table,$clname){
  $Query="SHOW COLUMNS FROM `$table` LIKE '$clname'";
  $result = $this->db->query($Query) or die("Get Enum value Query");
  if($result){
    $row = mysql_fetch_array( $result , MYSQL_NUM );
    $regex = "/'(.*?)'/";
    preg_match_all( $regex , $row[1], $enum_array );
    $enum_fields = $enum_array[1];
    return $enum_fields;
  }
  return false;
}

Saturday, 21 June 2014

Generate Password in alphanumeric using PHP


$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$password = substr( str_shuffle( $chars ), 0, $length );

Feet/Inches to Meters Converter & Lbs to Kgs Converter

 <!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8" />   <title>Feet/Inches ⇄...