forked from assembler-institute/php-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.php
More file actions
78 lines (41 loc) · 874 Bytes
/
strings.php
File metadata and controls
78 lines (41 loc) · 874 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
#TEXT
$txt = "Hello";
echo $txt;
echo "<br><br>";
#TEXT VARIABLE
echo "I said " . $txt . "<br><br>";
#CONCATENATE
$txt2 = "World";
echo "I said " . $txt . " " . $txt2;
echo "<br><br>";
#CASE SENSITIVE
$txt3 = "My car is white";
echo str_replace("white", "red", $txt3);
echo "<br><br>";
#REPLACE TEXT IN A STRING
$txt4 = "My car is WHITE";
echo str_ireplace("white", "red", $txt3);
echo "<br><br>";
#WRITE TEXT N TIMES
$txt5 = "It's sunny day <br>";
echo str_repeat($txt5, 3);
echo "<br><br>";
#OBTAIN THE LENGTH
echo strlen($txt);
echo "<br><br>";
#OBTAIN POSITION
echo strpos($txt2, "o");
echo "<br><br>";
#CAPITALIZED
$txtU = strtoupper($txt);
echo $txtU;
echo "<br><br>";
#LOWERCASE
$txt2L = strtolower($txt2);
echo $txt2L;
echo "<br><br>";
#OBTAIN TEXT SUBSTRING FROM A GIVEN POSITION
echo substr($txt, -3);
echo "<br><br>";
?>