\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Sara (lasago)} \pdfinfo{ /Title (1eva-php.pdf) /Creator (Cheatography) /Author (Sara (lasago)) /Subject (1EVA PHP Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{E9C2FF} \definecolor{LightBackground}{HTML}{F9EFFF} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{1EVA PHP Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Sara (lasago)} via \textcolor{DarkBackground}{\uline{cheatography.com/70899/cs/18250/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Sara (lasago) \\ \uline{cheatography.com/lasago} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 19th February, 2019.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Tipos de variable}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\$foo = (int) \$bar;} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\$foo = "1";} \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{p{1.727 cm} p{1.727 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Variables}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{define("PI", 3.14159265);} \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{6.908 cm} x{10.362 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Imprimir}} \tn % Row 0 \SetRowColor{LightBackground} var\_dump(\$b, \$c); & muestra valor de variables \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} print\_r (\$a); & o mesmo \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Arrays}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{\$a{[}{]}=„a‟;} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{\$moneda{[}"francia"{]}="Franco";} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{\$a{[}0{]}{[}1{]}=„Hola‟;} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{} \tn % Row Count 3 (+ 0) % Row 4 \SetRowColor{LightBackground} reset(\$array); & Resetea el puntero interno al principio del array. \tn % Row Count 6 (+ 3) % Row 5 \SetRowColor{white} end(\$array); & Mueve el puntero al último elemento del array. \tn % Row Count 9 (+ 3) % Row 6 \SetRowColor{LightBackground} next(\$array); & Mueve el puntero al proximo elemento del array. \tn % Row Count 12 (+ 3) % Row 7 \SetRowColor{white} prev(\$array); & Mueve el puntero al elemento previo respecto al actual \tn % Row Count 15 (+ 3) % Row 8 \SetRowColor{LightBackground} current(\$array); & Devuelve el elemento apuntado actualmente por el puntero interno del array. \tn % Row Count 19 (+ 4) % Row 9 \SetRowColor{white} key(\$array); & Devuelve el índice del elemento apuntado actualmente por el puntero interno del array, si es un vector asociativo devuelve la clave del elemento actual. \tn % Row Count 27 (+ 8) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{\$keys = array('foo', 5, 10, 'bar'); \$a = array\_fill\_keys(\$keys, 'banana');} \tn % Row Count 29 (+ 2) % Row 11 \SetRowColor{white} \seqsplit{\$array1=each(\$array)} & Devuelve los valores correspondientes al elemento actual del array y mueve el puntero al elemento siguiente. Si es un vector asociativo devuelve clavevalor, si es un vector común devuelve indice-valor \tn % Row Count 40 (+ 11) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Arrays (cont)}} \tn % Row 12 \SetRowColor{LightBackground} array bidimensional & \$comida = array( "frutas" =\textgreater{} array( "fresas" =\textgreater{} '35kcal', "frambuesa" =\textgreater{} '43kcal'),"carne" =\textgreater{} array( "babilla de ternera" =\textgreater{} '131kcal', "ala de pollo" =\textgreater{} '217kcal', "bacon" =\textgreater{} '682kcal' ));\{\{nl\}\}foreach(\$comida as \$tipo =\textgreater{} \$piezas)\{ foreach(\$piezas as \$pieza =\textgreater{} \$calorias)\{ echo "En \$tipo hay \$pieza, que tiene \$calorias por 100 gramos \textless{}br\textgreater{}"; \} \} \tn % Row Count 23 (+ 23) % Row 13 \SetRowColor{white} sort(\$array); & Ordena un vector según los valores de sus elementos, si este es asociativo considera claves y valores como elementos comunes (no los distingue). Ordena en orden ascendiente \tn % Row Count 32 (+ 9) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Arrays (cont)}} \tn % Row 14 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{rsort(\$array);} \tn % Row Count 1 (+ 1) % Row 15 \SetRowColor{white} asort(\$array); & Ordena un vector según los valores de sus elementos pero manteniendo las asociaciones clave-valor. Ordena los pares ordenados clave-valor según "valor". \tn % Row Count 9 (+ 8) % Row 16 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{arsort(\$array);} \tn % Row Count 10 (+ 1) % Row 17 \SetRowColor{white} ksort(\$array); & Ordena un vector asociativo por los valores de sus "claves" teniendo en cuenta las asociaciones clave-valor. \tn % Row Count 16 (+ 6) % Row 18 \SetRowColor{LightBackground} uksort(\$array,funcion); & Ordena un vector asociativo por "clave" usando para comparar las claves la función pasada como parámetro. \tn % Row Count 22 (+ 6) % Row 19 \SetRowColor{white} uasort(\$array,funcion); & Ordena un vector por los "valores" de sus elementos preservando la relación clave-valor de un array asociativo usando para ordenar la funcion provista por el usuario \tn % Row Count 31 (+ 9) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Arrays (cont)}} \tn % Row 20 \SetRowColor{LightBackground} \seqsplit{array=array\_pad(\$mivector},tamaño,valor); & Rellena \$mivector con valor hasta que tenga tamaño elementos, si tamaño es positivo completa agregando elementos hacia la derecha, si es negativo completa hacia la izquierda. \tn % Row Count 9 (+ 9) % Row 21 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{list(\$a,\$b)=\$vector; //\$a=1, \$b=2} \tn % Row Count 10 (+ 1) % Row 22 \SetRowColor{LightBackground} \seqsplit{\$vec1=array\_merge(\$array1},\$array2,....); & Si los vectores son asociativos hace una unión de los vectores en donde si 2 o más vectores tienen la misma clave sólo una queda en el vector resultado. Si los vectores no son asociativos (indexados por número) entonces el resultado tiene todos los elementos de los "n" vectores concatenados. \tn % Row Count 26 (+ 16) % Row 23 \SetRowColor{white} \seqsplit{\$vec1=array\_slice(\$array},offset,cantidad) & Devuelve un sub-vector de \$array a partir del offset indicado y con la cantidad de elementos indicada,si cantidad no se especifica devuelve todos los elementos desde offset hasta el fin del vector. \tn % Row Count 36 (+ 10) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Arrays (cont)}} \tn % Row 24 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{\seqsplit{\$cantidad=count(\$vector);}} \tn % Row Count 1 (+ 1) % Row 25 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{\$arraysize = sizeof(\$lista);} \tn % Row Count 2 (+ 1) % Row 26 \SetRowColor{LightBackground} \$vec array\_combine ( array \$keys , array \$values ) & Crea un arreglo utilizando dos arreglos, uno para llaves y otro para sus valores. \tn % Row Count 7 (+ 5) % Row 27 \SetRowColor{white} shuffle(array); & Desordena en forma aleatoria los elementos de un vector. \tn % Row Count 10 (+ 3) % Row 28 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{\seqsplit{array=array\_reverse(array);}} \tn % Row Count 11 (+ 1) % Row 29 \SetRowColor{white} \seqsplit{array=compact(nombre\_var1},nombre\_var2,....,nombre\_varN); & Crea un vector asociativo cuyas claves son los nombres de las variables y los valores el contenido de las mismas. \tn % Row Count 17 (+ 6) % Row 30 \SetRowColor{LightBackground} \seqsplit{array\_walk(\$array1},funcion,variable\_extra); & array\_walk permite aplicar una función a todos y cada uno de los elementos de un vector. \tn % Row Count 22 (+ 5) % Row 31 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{\$a = array\_fill(5, 6, 'banana');} \tn % Row Count 23 (+ 1) % Row 32 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{\$key = array\_search('green', \$array); // \$key = 2;} \tn % Row Count 24 (+ 1) % Row 33 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{\$stack = array("orange", "banana"); array\_push(\$stack, "apple", "raspberry");} \tn % Row Count 26 (+ 2) % Row 34 \SetRowColor{LightBackground} \seqsplit{\&array1=array\_keys(\$array)} & Devuelve un vector con todas las claves de un vector asociativo. \tn % Row Count 30 (+ 4) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Arrays (cont)}} \tn % Row 35 \SetRowColor{LightBackground} \seqsplit{\&array1=array\_values(\$array)} & Devuelve un vector con todos los valores de un vector asociativo \tn % Row Count 4 (+ 4) % Row 36 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{Arrayntercambiado = array\_flip ( array \$array )} \tn % Row Count 5 (+ 1) % Row 37 \SetRowColor{LightBackground} string implode ( array \$pieces ) & Une elementos de un array en un string \tn % Row Count 7 (+ 2) % Row 38 \SetRowColor{white} \$oferta = array( "idOferta" =\textgreater{} "2344", "titulo" =\textgreater{} "Oferta de viaje a Tanger", "descripcion" =\textgreater{} "Oferta de viaje que incluye Ferry ida y vuelta y alojamiento" ); extract(\$oferta); /{\emph{ Obtenemos las siguientes variables: \$idOferta, \$titulo, \$descripcion }}/ & , convirte la pareja clave/valor de un array asociativo en variables PHP. \tn % Row Count 21 (+ 14) % Row 39 \SetRowColor{LightBackground} \$clothes = 't-shirt'; \$size = 'medium'; \$color = 'blue'; \$array = compact('clothes', 'size', 'color'); print\_r(\$array); // Array ( {[}clothes{]} =\textgreater{} t-shirt {[}size{]} =\textgreater{} medium, {[}color{]} =\textgreater{} blue ) & hace un array asociativo de variables \tn % Row Count 31 (+ 10) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.9442 cm} x{9.3258 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Funciones con cadena}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{\seqsplit{\$cadenaMinus=strtolower(\$cadena);}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{\$str = mb\_strtoupper(\$str);} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} ucfirst() & converte la primera letra del texto a mayúscula. \tn % Row Count 5 (+ 3) % Row 3 \SetRowColor{white} \textbackslash{}n & avance de línea \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} \textbackslash{}r & retorno de carro \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} \textbackslash{}e & escape \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} \textbackslash{}f & avance de página \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} \textbackslash{}" & escapar carácter \tn % Row Count 10 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{if(preg\_match(\$patron,\$cadena{[}\$i{]}))} \tn % Row Count 11 (+ 1) % Row 9 \SetRowColor{white} echo trim(\$str,"Hed!"); & elimina los espacios que existan al inicio y/o al final de una cadena. \tn % Row Count 15 (+ 4) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{echo preg\_replace(\$pattern, \$replacement, \$string);} \tn % Row Count 17 (+ 2) % Row 11 \SetRowColor{white} echo str\_repeat("-=", 10); & la cadena indicada el número de veces que indica el 2º parámetro. \tn % Row Count 21 (+ 4) % Row 12 \SetRowColor{LightBackground} \seqsplit{\$i=strlen(\$cadena)} & longitud \tn % Row Count 22 (+ 1) % Row 13 \SetRowColor{white} \$pos = strpos(\$mystring, \$findme); & Find the position of the first occurrence of a substring in a string \tn % Row Count 26 (+ 4) % Row 14 \SetRowColor{LightBackground} strchr (\$texto, "u"); & indica la posición de un caracter (2º parámetro) dentro de la cadena (parámetro1) . \textless{}? \tn % Row Count 31 (+ 5) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.9442 cm} x{9.3258 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Funciones con cadena (cont)}} \tn % Row 15 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{echo str\_replace("es", "**", \$texto, \$reemplazos );} \tn % Row Count 2 (+ 2) % Row 16 \SetRowColor{white} echo substr(\$texto,0,5); & Extraer los primeros 6 caracteres. La primera posición es la 0 y la ultima es la 5 \tn % Row Count 6 (+ 4) % Row 17 \SetRowColor{LightBackground} \$array = explode(",", \$cadena); & convierte un string en un array, en función del delimitador indicado (parametro1) \tn % Row Count 10 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Formularios}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{if(isset(\$\_REQUEST{[}'cadena'{]}))\{} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{\$cadena=\$\_REQUEST{[}'cadena'{]};} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{\textless{}form action="accion.php" name="reves" method="request"\textgreater{}} \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{\textless{}input type="text" name="cadena" id="cadena"\textgreater{}\textless{}/input\textgreater{}} \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} \textless{}input type="submit" value="Enviar" id="enviar"\textgreater{}\textless{}/input\textgreater{} & \$enviar= \$\_REQUEST{[}'enviar'{]}; \tn % Row Count 9 (+ 3) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{\textless{}INPUT TYPE="radio" NAME="sexo" VALUE="M" CHECKED\textgreater{}Mujer} \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} \textless{}INPUT TYPE="checkbox" NAME="extras{[}{]}" VALUE="garaje" CHECKED\textgreater{}Garaje & \$extras = \$\_REQUEST{[}'extras'{]}; foreach(\$extras as \$extra) print("\$extra\textless{}BR\textgreater{}\textbackslash{}n"); \tn % Row Count 16 (+ 5) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{\textless{}SELECT NAME="color"\textgreater{} \textless{}OPTION VALUE="rojo" SELECTED\textgreater{}Rojo \textless{}OPTION VALUE="verde"\textgreater{}Verde \textless{}OPTION VALUE="azul"\textgreater{}Azul \textless{}/SELECT\textgreater{}} \tn % Row Count 19 (+ 3) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{\textless{}SELECT MULTIPLE SIZE="3" NAME="idiomas{[}{]}"\textgreater{} \textless{}OPTION VALUE="ingles" SELECTED\textgreater{}Inglés \textless{}OPTION VALUE="frances"\textgreater{}Francés \textless{}OPTION VALUE="aleman"\textgreater{}Alemán \textless{}OPTION VALUE="holandes"\textgreater{}Holandés \textless{}/SELECT\textgreater{}} \tn % Row Count 23 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{p{1.727 cm} p{1.727 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Funciones número}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{rand(1,10);} \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Estructuras repetitivas}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{foreach (\$arr as \&\$value) \{ \$value = \$value * 2; \}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} foreach (\$arr as \&\$valueUser =\textgreater{} \$infoUser) \{ & \$arr = array ( 'Usuario 1:' =\textgreater{} array( 'nombre' =\textgreater{}"A", 'genero' =\textgreater{} 'F') \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{foreach \$infoUser as \$content\{\}\}} \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{p{1.727 cm} p{1.727 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Funciones}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{function \seqsplit{porReferencia(\&\$cadena)} \{ \$cadena = 'Si cambia'; \}} \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.9442 cm} x{9.3258 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Comprobaci'on de datos}} \tn % Row 0 \SetRowColor{LightBackground} if (isset(\$var)) \{ & Determine if a variable is set and is not NULL \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} if \seqsplit{(is\_numeric(\$numero))} \{ & Esta función se puede utilizar para comprobar si el dato que se ha recibido es un número (o se puede interpretar como número). \tn % Row Count 10 (+ 7) % Row 2 \SetRowColor{LightBackground} \seqsplit{ctype\_digit(\$valor)} & comprueba si el dato es un número entero positivo (sin decimales). \tn % Row Count 14 (+ 4) % Row 3 \SetRowColor{white} \seqsplit{array\_key\_exists(\$indice}, \$matriz) & devuelve true si un elemento determinado de una matriz existe o no. \tn % Row Count 18 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.4623 cm} x{8.8077 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Regex}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{preg\_match(\$pattern, substr(\$subject,3), \$matches, PREG\_OFFSET\_CAPTURE);} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{comprobar si un string empieza con unos caracteres concretos, despues de los delimitadores, el patron comenzará con el signo \textasciicircum{}, parea el final \$} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} if(preg\_match("/\textasciicircum{}calle/i", \$direccion)) & Por defecto, las búsquedas son sensibles a mayúsculas y minúsculas, para cambiar esto se puede añadir una i de insensitive al final. \tn % Row Count 12 (+ 7) % Row 3 \SetRowColor{white} - & Indica rango de caracteres. \tn % Row Count 14 (+ 2) % Row 4 \SetRowColor{LightBackground} \textbackslash{}d & Cualquier carácter numérico {[}0-9{]} \tn % Row Count 16 (+ 2) % Row 5 \SetRowColor{white} \textbackslash{}D & Cualquier carácter no numérico {[}\textasciicircum{}0-9{]} \tn % Row Count 18 (+ 2) % Row 6 \SetRowColor{LightBackground} \textbackslash{}s & Cualquier espacio {[}\textbackslash{}t\textbackslash{}n\textbackslash{}r\textbackslash{}f\textbackslash{}v{]} \tn % Row Count 20 (+ 2) % Row 7 \SetRowColor{white} \textbackslash{}S & Cualquiera que no sea espacio {[}\textasciicircum{} \textbackslash{}t\textbackslash{}n\textbackslash{}r\textbackslash{}f\textbackslash{}v{]} \tn % Row Count 23 (+ 3) % Row 8 \SetRowColor{LightBackground} \textbackslash{}w & Cualquier carácter alfanumérico {[}a-zA-Z0-9\_{]} \tn % Row Count 26 (+ 3) % Row 9 \SetRowColor{white} \textbackslash{}W & Cualquier carácter no alfanumérico {[}\textasciicircum{}a-zA-Z0-9\_{]} \tn % Row Count 29 (+ 3) % Row 10 \SetRowColor{LightBackground} . & Match con cualquier caracter \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.4623 cm} x{8.8077 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Regex (cont)}} \tn % Row 11 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{echo preg\_match\_all('/linea\textbackslash{}Z/im', \$texto); // Devuelve: 1} \tn % Row Count 2 (+ 2) % Row 12 \SetRowColor{white} {[}{]} & permiten agrupar creando rangos. \tn % Row Count 4 (+ 2) % Row 13 \SetRowColor{LightBackground} () & Nos permiten crear sub-expresiones, expresiones regulares contenidas dentro de otras: /a(bc.)+e/. \tn % Row Count 9 (+ 5) % Row 14 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{echo preg\_replace(\$pattern, \$replacement, \$string); ?\textgreater{}} \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{5.3537 cm} x{11.9163 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Funciones matemáticas}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{abs(-5) Devuelve: 5} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{pow(2,3) Devuelve: 8} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{. \$aNumeros = array(2, 45, 1, 230, 15); max(\$aNumeros) // Devuelve: 230} \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{\$aNumeros = array(2, 45, 23, 1, 230, 15); min(\$aNumeros) // Devuelve: 1} \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{rand() rand(1, 100) Devuelve un nº aleatorio entre 1 y 100} \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{sqrt(9) devuelve 3} \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} \$r = fmod(\$x, \$y); & Devuelve el resto en punto flotante (módulo) de la división de los argumentos \tn % Row Count 12 (+ 3) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{echo floor(4.3); //4} \tn % Row Count 13 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{echo ceil(4.3); //5} \tn % Row Count 14 (+ 1) % Row 9 \SetRowColor{white} intdiv() & división enetra \tn % Row Count 15 (+ 1) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{is\_nan()} \tn % Row Count 16 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \end{document}