forked from marcosrivasr/Curso-PHP-MySQL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02 strings.php
More file actions
49 lines (33 loc) · 755 Bytes
/
02 strings.php
File metadata and controls
49 lines (33 loc) · 755 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
<?php
// Funciones para strings
$mensaje = "Hoy voy a aprender mucho";
//longitud
echo strlen($mensaje);
echo "<br>";
//Número de palabras
echo str_word_count($mensaje);
echo "<br>";
//Reversa
echo strrev($mensaje);
echo "<br>";
//Encontrar texto
echo strpos($mensaje, "aprender");
echo "<br>";
//Reemplazar texto
echo str_replace("aprender", "nadar", $mensaje);
echo "<br>";
//Convertir a minúsculas
echo strtolower($mensaje);
echo "<br>";
//Convertir a mayúsculas
echo strtoupper($mensaje);
echo "<br>";
//Comparar cadenas
echo strcmp("a", "a");
echo "<br>";
//Substraer cadena
echo substr($mensaje, 10, 7);
echo "<br>";
//Remover espacios en blanco
echo trim(" hola soy Marcos");
?>