Jump to content

Archived

This topic is now archived and is closed to further replies.

redarrow

beginers example for substr floor strtotime wordwrap refrence i shere ok.

Recommended Posts

edit:
change any redarrow to john or it will be wrong ok.


I have been leaning the date conversion with strtotime and floor, also i have lern to use substr to limit the charecters, and i have been learning wordwrap to add a brake from the database.

heres my example for the beginers ok.

I hope this helps any beginer good luck.


<?
//start

//day conversion.

$date1="10-10-2006";
$date2="10-11-2006";

$start=strtotime($date1);

$end=strtotime($date2);

$sum=$end-$start;

$result1=floor($sum/86400);

//end

echo" this is a day conversion $result1 <br>";

//start

// see words to desire lenth.

$text="my name is redarrow and i love php";

$result2=substr($text,0,16);

//end

echo " this is a letter deduction $result2<br>";

// start.
$word="my name is redarrow and i love php";

$result3=wordwrap($word,16,"<br>",1);

// end.

echo " this is a sentence with a brake $result3 <br> ";

?>

Share this post


Link to post
Share on other sites
Feel free to explain what the functions and their parameters do. :D

Share this post


Link to post
Share on other sites
ok heres goes a brake down

my spelling is bad but i tried to exsplain good luck all.

<?
//start

//day conversion.

//This is the first date.
$date1="10-10-2006";

//This is the scound date.
$date2="10-11-2006";

// strtotime converts the $date1 to a timestamp varable $start.
$start=strtotime($date1);

// strtotime converts the $date2 to a timestamp varable $end.
$end=strtotime($date2);

//varable $sum was set to take $end varable from $start varable
$sum=$end-$start;

// $result1 is set to floor the seconds from $sum varable there are 86400 secons in a day.
$result1=floor($sum/86400);


//end
// echo the result from the $result1 varable the echo result is 31 days from the conversion of floor.
echo" this is a day conversion $result1 <br>";

//start

// see words to desire lenth.

// set the varable $text to a sentence the sentence is 30 charecters long.
$text="my name is john and i love php";

// set $result2 varable to substr to show the number of charecters to show on a page 0 means start from and 16 is the number of charecter to see echoed out
$result2=substr($text,0,16);

//end
// echo out the $result2 the echo result is
//my name is john substr is told only to show the first 16 charecters.
echo " this is a letter deduction $result2<br>";

// start.

// set a varable $word what has 30 charecters
$word="my name is john and i love php";

// set varable $result3 to wordwrap to have a brake for a new line at charecter 16 "<br>" 1 is defult.
$result3=wordwrap($word,16,"<br>",1);

// end.
// echo out the $result3 you get
//my name is john
//i love php
echo " this is a sentence with a brake $result3 <br> ";

?>

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.