Jump to content

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


redarrow

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> ";

?>
Link to comment
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> ";

?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.