info230review - INFO 230 Midterm Review Arrays: $array=...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
INFO 230 Midterm Review Arrays: $array= array("key1"=>"val1", "key2"=>"val2"); foreach ($array as $key=>$val){ } To print an array (pre tags to keep nice formatting and indents): <pre> print_r($array); </pre> PHP functions: Defining your own function: $string=”apple”; $string2= reverse(“apple”); Function reverse ($value1, …) { //PHP code here Return $value1; } Isset String functions: trim, strtoupper, strtolower, split, join $array = split(“,” “ab, c, de, f”); Htmlentities and checking user input Regular expressions: Ereg(‘[fgh]’, “hello world”) = true * = zero or more + = one or more | = or ^ = starting $ = ending . = character classes (e.g. [0-9]) [A-Z]* = zero or more [a-z]+ = one or more [0-9]{5,7} = 5 to 7 numbers in string (can be letters, etc) ^[0-9]{5}$ = only 5 numbers in string, no letters, etc. ereg_replace(string to be replaced, replacement string, whole string) $str = ereg_replace(‘p’, ‘t’, “apple”) = attle $str = ‘c’ . $str (=cattle) Files and file functions : Fopen
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/01/2008 for the course INFO 2300 taught by Professor Williamson during the Spring '08 term at Cornell University (Engineering School).

Page1 / 3

info230review - INFO 230 Midterm Review Arrays: $array=...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online