\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{Syshella}
\pdfinfo{
  /Title (php.pdf)
  /Creator (Cheatography)
  /Author (Syshella)
  /Subject (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}{A3A3A3}
\definecolor{LightBackground}{HTML}{F3F3F3}
\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{PHP Cheat Sheet}}}} \\
    \normalsize{by \textcolor{DarkBackground}{Syshella} via \textcolor{DarkBackground}{\uline{cheatography.com/128892/cs/34652/}}}
\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}Syshella \\
  \uline{cheatography.com/syshella} \\
  \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 October, 2022.\\
   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{multicols*}{3}

\begin{tabularx}{5.377cm}{x{1.96811 cm} x{1.55618 cm} x{1.05271 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Strings and variables}}  \tn
% Row 0
\SetRowColor{LightBackground}
Print as html & echo "This is my string"; & This is my string \tn 
% Row Count 2 (+ 2)
% Row 1
\SetRowColor{white}
String & "Hello World!"; & Hello World! \tn 
% Row Count 4 (+ 2)
% Row 2
\SetRowColor{LightBackground}
Escape sequence & "Hello \textbackslash{}"World\textbackslash{}"!"; & Hello "World"! \tn 
% Row Count 6 (+ 2)
% Row 3
\SetRowColor{white}
Concatenation (Literal) & echo "one" . "two"; & onetwo \tn 
% Row Count 8 (+ 2)
% Row 4
\SetRowColor{LightBackground}
Variable creation and assignment & \$var = "Hello"; &  \tn 
% Row Count 10 (+ 2)
% Row 5
\SetRowColor{white}
Variable contatenation & echo \$var . " you"; & Hello you \tn 
% Row Count 12 (+ 2)
% Row 6
\SetRowColor{LightBackground}
Variable parsing & echo "\$var you"; & Hello you \tn 
% Row Count 14 (+ 2)
% Row 7
\SetRowColor{white}
Expanding string & echo "\$\{var\}oo! you!; & Hellooo! you! \tn 
% Row Count 16 (+ 2)
% Row 8
\SetRowColor{LightBackground}
Concatenating assigmente & \$var .= " world"; & Hello world \tn 
% Row Count 18 (+ 2)
% Row 9
\SetRowColor{white}
Assign by reference & \$var1 = \$var2; &  \tn 
% Row Count 20 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}---}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Types and operators}}  \tn
% Row 0
\SetRowColor{LightBackground}
String & \$string = "Hello"; \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
Int & \$int = 4; \tn 
% Row Count 2 (+ 1)
% Row 2
\SetRowColor{LightBackground}
Float & \$float = 4.2; \tn 
% Row Count 3 (+ 1)
% Row 3
\SetRowColor{white}
Exponentiation & 4**2 -{}-\textgreater{} (4\textasciicircum{}2) = 64 \tn 
% Row Count 4 (+ 1)
% Row 4
\SetRowColor{LightBackground}
Modulo & 7 \% 3 -{}-\textgreater{} 1 \tn 
% Row Count 5 (+ 1)
% Row 5
\SetRowColor{white}
Mathematical assignment operator & \$int += 3; \tn 
% Row Count 7 (+ 2)
% Row 6
\SetRowColor{LightBackground}
Increment and decrement & \$int ++; \tn 
% Row Count 9 (+ 2)
% Row 7
\SetRowColor{white}
Global variable & global \%var; //Inside a function to access a value declared outside the function \tn 
% Row Count 13 (+ 4)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{5.377cm}}{- Result of adding up two floats 9.9 and 1.0 will return an integer, since the result is 10 and evaluates to a whole number. Applies to every calculation. The reverse is also true. \newline - Operations order: () \textgreater{}\textgreater{} {\emph{* \textgreater{}\textgreater{} }} and / \textgreater{}\textgreater{} + and -}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Functions}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{function greeting(\$value = "Sam") // Default value = Sam \newline \{ \newline     return "Hello \$value!"; \newline \} \newline  \newline \$return\_value = greeting("Tom"); \newline  \newline echo \$return\_value; //Prints: Hello Tom! \newline echo greeting(); //Prints: Hello Sam! \newline  \newline function addXPermanently (\&\$param) // Passed by reference \newline \{ \newline   \$param = \$param . "X"; \newline   echo \$param; \newline \}; \newline \$word = "Hello"; \newline addXPermanently(\$word); // Prints: HelloX \newline echo \$word; // Prints: HelloX} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Built-in Functions}}  \tn
% Row 0
\SetRowColor{LightBackground}
gettype(4); // Prints: integer & Get the type of the parameter given as a string \tn 
% Row Count 3 (+ 3)
% Row 1
\SetRowColor{white}
var\_dump(4); // Prints: int(1000000) & Prints details about the argument \tn 
% Row Count 5 (+ 2)
% Row 2
\SetRowColor{LightBackground}
strive("Hello"); // Prints: olleH & Prints the string in reversed order \tn 
% Row Count 7 (+ 2)
% Row 3
\SetRowColor{white}
\seqsplit{strtolower("Hello");} // Prints: hello & Lower case the string \tn 
% Row Count 9 (+ 2)
% Row 4
\SetRowColor{LightBackground}
str\_repeat("Hello", 2); // Prints: HelloHello & Repeats the string the number of times specified \tn 
% Row Count 12 (+ 3)
% Row 5
\SetRowColor{white}
\seqsplit{substr\_count(\$string}, \$substring); & Number of instances of a substring within a string \tn 
% Row Count 15 (+ 3)
% Row 6
\SetRowColor{LightBackground}
abs(-2); // Returns 2 & Returns the absolute value \tn 
% Row Count 17 (+ 2)
% Row 7
\SetRowColor{white}
round(3.8); // Returns 4 & Rounds a number \tn 
% Row Count 19 (+ 2)
% Row 8
\SetRowColor{LightBackground}
rand(); & Returns a random number between 0 and the largest allowed \tn 
% Row Count 22 (+ 3)
% Row 9
\SetRowColor{white}
rand(3, 10); & Returns a number between 3 and 10 inclusive \tn 
% Row Count 25 (+ 3)
% Row 10
\SetRowColor{LightBackground}
getrandmax() & Returns the largest random number value possible \tn 
% Row Count 28 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{2.63781 cm} x{2.33919 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Data Structures}}  \tn
% Row 0
\SetRowColor{LightBackground}
Array & \$my\_array = array(0, 1, "A"); \tn 
% Row Count 2 (+ 2)
% Row 1
\SetRowColor{white}
Array & \$my\_array = {[}0, 1, "A"{]}; \tn 
% Row Count 4 (+ 2)
% Row 2
\SetRowColor{LightBackground}
Print array & \seqsplit{print\_r(\$my\_array);} \tn 
% Row Count 6 (+ 2)
% Row 3
\SetRowColor{white}
Returns array separated by value & implode(",  ", \$my\_array); \tn 
% Row Count 8 (+ 2)
% Row 4
\SetRowColor{LightBackground}
Access array index & \$y\_array{[}1{]}; \tn 
% Row Count 9 (+ 1)
% Row 5
\SetRowColor{white}
Adds the element at the end of the array & \$my\_array = "new element"; \tn 
% Row Count 11 (+ 2)
% Row 6
\SetRowColor{LightBackground}
Replace the element & \$my\_array{[}0{]} = "new first element"; \tn 
% Row Count 13 (+ 2)
% Row 7
\SetRowColor{white}
Pops the last element and returns it & \seqsplit{array\_pop(\$my\_array);} \tn 
% Row Count 15 (+ 2)
% Row 8
\SetRowColor{LightBackground}
Push the elements to the end of the array and return its size & array\_push("A", "B"); \tn 
% Row Count 18 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{5.377cm}}{count(\$array); // Returns the number of elements in the array \newline  \newline  \newline - Different types are allowed in an array}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Map}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{{\bf{Associative array}} \newline \$my\_array = {[}"panda" =\textgreater{} "very cute", "lizard" =\textgreater{} "cute", "cockroach" =\textgreater{} "not very cute"{]}; \newline  \newline {\bf{Array function}} \newline \$about\_me = array( \newline     "fullname" =\textgreater{} "Aisle Nevertell", \newline     "social" =\textgreater{} 123456789 \newline ); \newline  \newline echo implode(\$my\_array); // Prints only the values \newline print\_r(\$my\_array); // Prints keys and values \newline  \newline \$my\_array = {[}"new"{]} = "new item"; // Adds new element \newline  \newline \$favorites = {[}"favorite\_food"=\textgreater{}"pizza", "favorite\_place"=\textgreater{}"my dreams", "FAVORITE\_CASE"=\textgreater{}"CAPS", "favorite\_person"=\textgreater{}"myself"{]}; \newline   \newline echo  \$favorites{[}"favorite" . "\_" . "food"{]};  \newline // Prints: pizza \newline   \newline \$key =  "favorite\_place"; \newline echo  \$favorites{[}\$key{]};   \newline // Prints: my dreams \newline   \newline echo \$favorites{[}strtoupper("favorite\_case"){]}; \newline // Prints: CAPS \newline  \newline unset("my\_array{[}"new"{]}); // Delete the "new" element if exists} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{key =\textgreater{} value \newline Works as a dictionary. Arrays are maps where the key is the index.  \newline Key can be number or characters.}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{2.28942 cm} x{2.68758 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Libraries}}  \tn
% Row 0
\SetRowColor{LightBackground}
\textless{}?php include 'footer.html';?\textgreater{} & Includes the HTML file where specified \tn 
% Row Count 2 (+ 2)
% Row 1
\SetRowColor{white}
\textless{}?php require 'somefile.php'; ?\textgreater{} & Requires the specified file \tn 
% Row Count 4 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PHP \& HTML}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{5.377cm}}{\textless{}?php \newline \$lucky\_number = 5 * 2 - 1; \newline   \newline echo "\textless{}h1\textgreater{}Your lucky number is \$\{lucky\_number\}\textless{}/h1\textgreater{}"; \newline ?\textgreater{} \newline  \newline  \newline \textless{}?php \newline function makeHeaderGreeting (\$name)\{ \newline   return "\textless{}h1\textgreater{}Hello, \$\{name\}!\textless{}/h1\textgreater{}"; \newline \} \newline   \newline echo \seqsplit{makeHeaderGreeting("World");} \newline ?\textgreater{} \newline  \newline \$about\_me = {[} \newline   "name" =\textgreater{} "Aisle Nevertell", \newline   "birth\_year" =\textgreater{} 1902, \newline   "favorite\_food" =\textgreater{} "pizza" \newline {]}; \newline  \newline function calculateAge (\$person\_arr)\{ \newline   \$current\_year = date("Y"); \newline   \$age = \$current\_year - \$person\_arr{[}"birth\_year"{]}; \newline   return \$age; \newline \} \newline ?\textgreater{} \newline \textless{}h1\textgreater{}Welcome!\textless{}/h1\textgreater{} \newline \textless{}h2\textgreater{}About me:\textless{}/h2\textgreater{} \newline \textless{}?php    \newline   echo "\textless{}h3\textgreater{}Hello! I'm \{\$about\_me{[}"name"{]}\}!\textless{}/h3\textgreater{}"; \newline   echo "\textless{}p\textgreater{} I'm " . \seqsplit{calculateAge(\$about\_me)}. " years old! That's pretty cool, right?\textless{}/p\textgreater{}"; \newline   echo "\textless{}div\textgreater{}What more is there to say? I love \{\$about\_me{[}"favorite\_food"{]}\}, and that's pretty much it!\textless{}/div\textgreater{}"; \newline ?\textgreater{}} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{5.377cm}{x{1.84149 cm} x{3.13551 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Data access in Forms}}  \tn
% Row 0
\SetRowColor{LightBackground}
\$\_GET & Non sensible information \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
\$\_POST & Used to send sensitive information \tn 
% Row Count 3 (+ 2)
% Row 2
\SetRowColor{LightBackground}
\$\_GET{[}'user'{]} & Retrieves the value sent through the user get form \tn 
% Row Count 5 (+ 2)
% Row 3
\SetRowColor{white}
\$\_isset(\$\_POST{[}'send'{]}) & Check if send has a value \tn 
% Row Count 7 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{5.377cm}}{When a form is submitted values are received contained in an associative array.}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}


% That's all folks
\end{multicols*}

\end{document}