lecture25

lecture25 - PIC 40A Lecture 25: More PHP Arrays PHP Array...

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

View Full Document Right Arrow Icon
PIC 40A Lecture 25: More PHP Arrays
Background image of page 1

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

View Full DocumentRight Arrow Icon
PHP Array functions • unset – deletes the contents of a scalar variable, an array entry, or an entire array • count – returns the number of elements in an array • sizeof – same as count
Background image of page 2
Example $list = array(1,2,3,4); #keys 0,1,2,3 $a = 5; unset ($list[2]); # now $list has keys 0,1,3 and elements 1,2,4 unset ($list); #now $list is NULL unset ($a); #now $a is NULL
Background image of page 3

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

View Full DocumentRight Arrow Icon
PHP Array Conversions • explode($delim, $str) – explodes a string $str into substrings using the given delimiter $delim and returns them in an array • implode($delim, $strarray) – does the inverse of explode by joining the elements of $strarray as a string while wedging the given $delim in between each element. The resulting string is returned.
Background image of page 4
Example $str = "a:b:c:d"; $a = explode (":", $str); 0123 $a $str = implode ("^", $a); $str now has value "a^b^c^d" "a" "b" "c" "d"
Background image of page 5

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

View Full DocumentRight Arrow Icon
Anatomy of a PHP Array Key Value Next current key-based hash functions Hash Function sequential access functions
Background image of page 6
Accessing array elements in sequential order • Every array has an internal pointer which points to the "current" element of the array
Background image of page 7

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

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

Page1 / 22

lecture25 - PIC 40A Lecture 25: More PHP Arrays PHP Array...

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

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