-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInbuiltStringFunction.php
More file actions
51 lines (39 loc) · 899 Bytes
/
InbuiltStringFunction.php
File metadata and controls
51 lines (39 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
//concatenation in php
$str1="Greesma";
$str2="Thapa";
$fullname=$str1." ".$str2;
echo $fullname;
echo "<br>";
//length of a string
echo strlen($str1);
echo "<br>";
//wordcount of a string
$a="the quick brown fox jumps over a lazy dog";
echo str_word_count($a);
echo "<br>";
//replace a word in a string
echo str_replace("fox", "wolf", $a);
echo "<br>";
//reverse function
echo strrev($a);
echo "<br>";
//uppercase
echo strtoupper($str1);
echo "<br>";
//lowercase
$d="HELLO";
echo strtolower($d);
echo "<br>";
//position of a word
echo strpos($a, "quick");
echo "<br>";
//other functions
echo substr($a, 5);//gives all the word with and after index 5
echo "<br>";
echo substr($a, 4, 9); //find the word between two given indexes i.e. between 4 and 9
echo "<br>";
$g=" baby";
echo trim($g); //removes unwanted spaces
echo "<br>";
echo "$g[4]";//prints the character at the index 1