string function of php
Post on 02-Jun-2018
235 Views
Preview:
TRANSCRIPT
-
8/10/2019 String Function of PHP
1/36
PHP
-
8/10/2019 String Function of PHP
2/36
chr()
The chr() function returns a character from thespecified ASCII value.
Syntax:
chr(ascii)
-
8/10/2019 String Function of PHP
3/36
Example
Output:
5
A
d
-
8/10/2019 String Function of PHP
4/36
ord()
The ord() function returns the ASCII value ofthe first character of a string.
Syntax:
ord(string)
-
8/10/2019 String Function of PHP
5/36
Example
Output:
97
97
-
8/10/2019 String Function of PHP
6/36
strtolower()
This function converts the string to lower case.
Syntax:
strtolower(string);
-
8/10/2019 String Function of PHP
7/36
Example
Output:
hello bca 3 sem
-
8/10/2019 String Function of PHP
8/36
strtoupper()
This function converts the string to upper case.
Syntax:
strtoupper();
-
8/10/2019 String Function of PHP
9/36
-
8/10/2019 String Function of PHP
10/36
-
8/10/2019 String Function of PHP
11/36
-
8/10/2019 String Function of PHP
12/36
ltrim()
The ltrim() function is used to remove whitespaces or other predefined characters form
the left side of the string.
Syntax:
The ltrim() function is used to remove white spaces or other predefined characters form the left side of the string.
ltrim(string_name, char_list)
-
8/10/2019 String Function of PHP
13/36
Example
Output:
Hello BCA 3 Sem
Hello BCA 3 Sem
-
8/10/2019 String Function of PHP
14/36
-
8/10/2019 String Function of PHP
15/36
Example
Output:
Hello BCA 3 Sem
Hello BCA 3 S
-
8/10/2019 String Function of PHP
16/36
trim()
The trim() function is used to remove the whitespaces and other predefined characters from the left
and right sides of a string.
Syntax:
trim(string_name, char_list)
-
8/10/2019 String Function of PHP
17/36
Example
-
8/10/2019 String Function of PHP
18/36
-
8/10/2019 String Function of PHP
19/36
-
8/10/2019 String Function of PHP
20/36
strcmp()
The strcmp() function is used to compare two strings.
Syntax:
This function returns:
0 - if the two strings are equal
0 - if string1 is greater than string2
strcmp(string1, string2)
-
8/10/2019 String Function of PHP
21/36
Example
0 -4 4
-
8/10/2019 String Function of PHP
22/36
strcasecmp()
The strcasecmp() function is used to compare two casesensitive strings.
Syntax:
This function returns:0 - if the two strings are equal
0 - if string1 is greater than string2
strcasecmp(string1, string2)
-
8/10/2019 String Function of PHP
23/36
Example 0 -4 4
-
8/10/2019 String Function of PHP
24/36
strpos()
The strpos() function returns the position of the first
occurrence of a string inside another string.
Syntax:
strpos(string,find,start)
-
8/10/2019 String Function of PHP
25/36
Example
6
-
8/10/2019 String Function of PHP
26/36
-
8/10/2019 String Function of PHP
27/36
Example
1
7
-
8/10/2019 String Function of PHP
28/36
-
8/10/2019 String Function of PHP
29/36
Example
-
8/10/2019 String Function of PHP
30/36
stristr()
The stristr() function searches for the first occurrence
of a string inside another string.
Syntax:
stristr(string,search)
-
8/10/2019 String Function of PHP
31/36
Example
atmiy
-
8/10/2019 String Function of PHP
32/36
str_replace()
The str_replace() function replaces some characters
with some other characters in a string.
Syntax:
E l
-
8/10/2019 String Function of PHP
33/36
ExampleAtmiya Rajkot
Replacements=1
Array ( [0] => one [1] => two [2] => four )
t ()
-
8/10/2019 String Function of PHP
34/36
strrev()
The strrev() function is used to reverse a string.
Syntax:
strrev(main_string)
E l
-
8/10/2019 String Function of PHP
35/36
Example
egelloC ayimtA
-
8/10/2019 String Function of PHP
36/36
Questions?
top related