PHP strlen() Function
The strlen() function returns the length of a string.Syntax
strlen(string)
Example
<?php
echo strlen("Hello world!");
?>
PHP substr() Function
Return part of a string
The substr() function returns a part of a string.
Syntax
substr(string,start,length)
Parameter | Description |
---|---|
string | Required. Specifies the string to return a part of |
start | Required. Specifies where to start in the string
|
length | Optional. Specifies the length of the returned string. Default is to the end of the string.
|
Get first n characters of a string
Examplesecho substr("Hello world",0,4);
Output is print "Hello"
$category_name=substr($cat['description'],3, strlen($cat['description'])-1);
PHP fmod() Function
The fmod() function returns the remainder (modulo) of x/y.
Syntax
fmod(x,y);
if(fmod($i, 2)==0){
// Reminder is zero.
}
else{
// Reminder is one.
}
Converting separate month, day and year values into a timestamp
using
setDate
funtion<?php
$date = new DateTime();
$date->setDate(2001, 2, 3);
echo $date->format('Y-m-d');
?>
No comments:
Post a Comment