PHP: Hypertext Preprocessor(PHP) is open source Scripting Language suited for Web development .

Here i give some date format and some PHP Programming hints

1. Date Format from DD/MM/YYYY to change YYYY/MM/DD


Input Billdate= DD/MM/YYYY
Code: $BillDate=substr($BillDate, 6, 4)."/".substr($BillDate,3, 2) ."/".substr($BillDate, 0, 2);
Output YYYY/MM/DD

2. Date Format from YYYY/MM/DD to change DD/MM/YYYY

Input $tody="YYYY/MM/DD"
Code: if(empty($tody)) { } elseif(!ereg("^([0-9]{4})/([0-9]{2})/([0-9]{2})$",$tody, $parts)) {

// Check the format echo "Error Message";

}

$BillDate="$parts[3]-$parts[2]-$parts[1]";

Output DD/MM/YYYY

3.Format a number
input : $Netamt=125045
Code : number_format($Netamt, 2, '.', '');
output: 1250.45

input : $Netamt=125045
Code : number_format($Netamt, 3, '.', '');
output: 125.045

4. File Writing Concept In PHP
File open with write mode , so here mansion that w, R for read,A for append.

$Bill="Bill.txt";
$fd=fopen($Bill,"w");
fwrite($fd,"\nSlNo\t". " RATE\t"."MATERIAL NAME\t\t"."QUANTITY"."   AMOUNT\n");
fwrite($fd," 1 ". " 250.00 "."Carbon Rod"."25"." 6250.00\n");
fclose($fd);

Output File(Bill.txt):
SlN    RATE   MATERIAL NAME          QUANTITY         AMOUNT
1        250.00    Carbon Rod                                    25                   6250.00

5.Wordwrap in php

Word wrap is used to wrapped string at the specified column first argument is input string and second argument is character Limit

$Word_val= wordwrap($input_value, 25, "\n"); // Here 25 character spacing

echo "".$Word_value."";


Like it on Facebook, +1 on Google, Tweet it or share this article on other bookmarking websites.

Comments (0)

There are no comments posted here yet