-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5_string_function.php
More file actions
40 lines (31 loc) · 987 Bytes
/
Copy path5_string_function.php
File metadata and controls
40 lines (31 loc) · 987 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
<?php
$name="Harry is a good boy";
echo $name;
echo "<br>";
//show the length of the string.
echo "The length of" . " my string is " . strlen($name);
echo "<br>";
/* count the word it means harry is a good boy total (5 word)
1 2 3 4 5 */
echo str_word_count($name);
echo "<br>";
// reverse the string.
echo strrev($name);
echo "<br>";
// search any string.
echo strpos($name,"is");
echo "<br>";
// replace any string with anyone. It means Harry = Rohan.
echo str_replace('Harry', 'Rohan', $name);
echo "<br>";
// repeat the string it means 2 = harry harry.
echo str_repeat($name, 2);
echo "<br>";
echo "<pre>";
// rtrim means right space is removed.
echo rtrim(" This is a good boy "); //you are the space in program then using pre tag you can do it
echo "<br>";
// ltrim means left space is removed.
echo "</pre>";
echo ltrim(" This is a good boy ");
?>