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
52 lines (38 loc) · 1.16 KB
/
strings.php
File metadata and controls
52 lines (38 loc) · 1.16 KB
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
<?php
#PRINT TEXT STRING
print "print a text string<br>";
#PRINT TEXT STRING THAT INT VARIABLES
$a = "print a text string";
print $a." two"; #se concatena con . o con coma
#  "Metodo html para dar espacios al contenido"
echo "<br><br>";
#REPLACE SENSITIVE
$city = "A mi me gusta Barcelona";
print_r(str_replace("Barcelona", "Paris", $city));
echo "<br><br>";
#NO SENSITIVE ( PUEDES CAMBIAR SIN QUE SEAN IDENTICOS)
$city = "A mi me gusta Madrid";
print_r(str_ireplace("maDriD", "Paris", $city));
echo "<br><br>";
#REPEAT
$king = "mamodo rules is a king";
echo str_ireplace("mamodo RULES", "Zatch", $king);
echo "<br><br>";
$dance = "LuL";
echo str_repeat($dance, 10);
echo "<br><br>";
#LENGTH TEXT SCREEN
$textstring = "a b c d e f uno dos tres cuatro y cinco";
echo strlen($textstring);
#Posicion de una palabra
echo strpos("Me encanta el php","php");
#Poner en mayuscula
echo strtoupper("me encanta php(mayuscula)");
echo "<br><br>";
#Poner en minuscula
echo strtolower("ME ENCANTA PHP(MINUSCULA)");
echo "<br><br>";
#Quitar y poner letras en una frase
$hola = "Hola mi nombre es Victor";
echo substr($hola, 6, -1);
?>