1. chr => it returns the Character string containing character specified by asciiii
Syntax : chr(ascii integer)
2. ord => it returns the ascii value of first character of the string...
Syntax : ord(character string)
<?php
$str1 = "vyom";
echo chr(65)
."<br/>"; // it returns the A. because A's ascii value is 65.
echo ord($str1) ."<br/>"; // it returns the f's ascii value
that is 118
?>
3. strtolower => it returns the string with lower characters
Syntax : strtolower(string variable)
4. strtolower => it returns the string with lower characters
Syntax : strtolower(string variable)
5.
strlen => it returns the length of the string
Syntax :
integer strlen(string
variable)
<?php
?>
$str1 = "VYOM Computer
Education"; echo strlen($str1) ."<br/>"; // it returns 23
6. ltrim => it removes whitespaces from the left
side.
Syntax : ltrim(string variable)
7. rtrim => it removes whitespaces from the right
side.
Syntax : rtrim(string variable)
8. trim => it removes whitespaces from the both
side.
Syntax : trim(string variable)
9. substr => it retuns part of the string.
Syntax : substr(string variable, integer position, integer length)
<?php
$str1 = "vyom computer
Education";
echo substr($str1,4,6); // it
returns compu 4 means from 5th character
and 6 means by next 6
character...
?>
10. strcmp => it Matches two string and returns …
11.
strcasecmp
=> it Matches two string using case insensitive and returns…
string1 is greater then string2 then it gives >0
string1 is less than string2
then it gives <0
if both the strings are equal then it will return 0 Syntax : int strcmp(string variable1, string variable2) Syntax : int strcasecmp(string
variable1, string variable2)
<?php
$str1 = "vyom"; //ascii of v is 118
$str2 = "VYOM"; // ascii of V is 86
echo strcmp($str1,$str2); //
it returns 1 because string1 is higher
echo strcasecmp($str1,$str2);
// it returns 0 because here both strings
are equal
?>
12. strpos => it find position of first occurrence of a string
Syntax : int strpos(string variable,character)
13. strrpos => it find position of first occurrence of a string
Syntax : int strrpos(string variable,character)
<?php
$str1 = "abcdef
abcdef";
$find = "d";
echo strpos($str1,$find) ."<br/>"; //it finds first character's position
it gives
3
echo strrpos($str1,$find); //it finds last occurence of character's position
it
gives 10
?>
14.
strstr =>
this will return
part of the string by which the character is specified along with the character
. this is case sensitive.
Syntax : string strstr(string variable,character)
15.
stristr => this will return part of the string by which the character is specified
along with the character . this
is case insensitive.
Syntax : string stristr(string
variable,character)
16.
str_replace=> this function is used to replace
the string with the characters which are specified. This function is case sensitive.
Syntax : string str_replace
(search string/array ,character to be replaced, original string)
<?php
?>
$str1 =
array('a','e','i','o','u');
echo str_replace($str1,'*','vyom');
//it returns vy*m
17. strrev => This function is reversing the string
Syntax : string strrev(string
variable)
<?php
$str1 = "abcd";
echo "Original is ==>
".$str1 ;
echo " <br/>Reverse
is==>".strrev($str1);
?>
18.
echo =>
this function is used to display
any value on the web-page
it does not return any thing and so the return type of this function is void.
Syntax: void echo “string value”;
19.
print => this function
is same as echo it will display
any value on browser but its return
type is integer. The main difference between print and echo is echo
function can display variables separated by comma.
Syntax: int print(argument1,argument2);
20. explode => The function breaks a string into an
array.
Syntax : array explode(separator,string,limit)
21. implode => The function returns a string from the elements of an array.
Syntax: string implode(separator,array)
22.
join => The function returns a string from the elements
of an array. function is an alias of the implode() function.
Syntax: string join(separator,array)
<?php
)
$str = 'one,two,three,four';
print_r(explode(',',$str));
//output: Array ( [0] => one [1] => two [2] => three [3]
=> four
$arr = array('Hello','World!','Beautiful','Day!');
echo implode("
",$arr)."<br>"; // Hello World! Beautiful Day! echo
join(" ",$arr)."<br>"; // Hello World! Beautiful Day!
?>
23.
md5 =>
The md5() function
calculates the MD5 hash of a string it converts 32bit hexadecimal
value of given variable.
Syntax : string md5(string variable)
<?php
?>
$str1 = “vyom computer
education”;
echo md5($str1); //it returns
61b6d46887efc55f448a2df9c870ffbc
24. str_split => The function splits a string into an
array.
Syntax : array str_split(string,length)
25. str_shuffle => The function randomly shuffles all the characters of a string.
Syntax : string str_shuffle(string)
<?php
print_r(str_shuffle("Hello"));
//eoHll or leloH or elHlo
?>
26.
strcspn => The strcspn()
function returns the number of characters (including whitespaces) found in a
string before any part of the specified characters are found.
Syntax: strcspn(string,char,start,end)
<?php
echo strcspn("Hello
world!","w",0,6); // The start position is 0 and the length of
//the search
string is 6.?> echo strcspn("Hello world!","w"); //
default starts from 0
?>
27. strpbrk => The function searches a string for any of the specified characters.
Syntax: string strpbrk(string,charlist)
<?php
echo strpbrk("Hello
world!","W");//no string founds echo "<br>";
echo strpbrk("Hello world!","w");//it founds
world!
?>
28. substr_compare => The function compares two strings from a specified
start position.
Syntax: substr_compare(string1,string2,startpos,length,case)
·
0 - if the two strings are equal
·
<0 - if string1 (from startpos) is less than string2
·
>0 - if string1 (from startpos) is greater than string2
<?php
echo
substr_compare("world","or",1,2); //0 echo
substr_compare("world","ld",-2,2); //0 echo
substr_compare("world","orl",1,2); //0
echo
substr_compare("world","OR",1,2,TRUE);//0 it is true then
case sensitive
echo
substr_compare("world","or",1,3); //1 echo
substr_compare("world","rl",1,2);//-1
?>
29. substr_count => The function counts the number of times a substring occurs in a string.
Syntax: int substr_count(string,substring,start,length)
30. ucfirst => The function converts the first character of a
string to uppercase.
Syntax: string ucfirst(string)
31. ucwords => The function converts the first character of
each word in a string to uppercase.
Syntax: string ucfirst(string)
<?php
echo ucwords("hello world!"); //Hello World!
?>
No comments:
Post a Comment