Php junkies(2)
来源:互联网 发布:免费会计核算软件 编辑:程序博客网 时间:2024/06/01 18:28
Strings (Edit)
n Accessing Individual Characters
Ø Strlen
Ø String is an array
n Cleaning Strings
Ø Removing Whitespace
trim() ltrim() rtrim()
n Changing Case
Ø Strtolower() strtoupper()
Ø Ucfirst() ucwords()
Strings (Encoding & Escaping)
n HTML
Ø Htmlentities()
EnT_COMPAT (the default) only double quotes
ENT_QUOTES both types of quotes
ENT_NOQUOTES only single quotes
Ø Htmlspecialchars() only html syntax character
Ø Removing HTML Tags
strip_tags()
Ø Extracting meta tags
get_meta_tags() keyword, author,description, etc
n URLs
Ø RFC
rawurlencode() rawurldecode() %20
Ø Query-string encoding
urlencode() urldecode() as plus(+) do not process current query string or cookies, use to generate
n SQL
Ø Addslashes()
Ø Stripslashes()
n C-string encoding use different database
Ø Addcslashes()
Ø Stripcslashes()
Strings (Comparing strings)
n Exact
Ø ==
n Approximate Equality
Ø Soundex()
Ø Meaphone()
Ø Similar_text()
Ø Levenshtein()
Strings (Manipulating and search Strings)
n Substrings
Ø Substr()
n Miscellaneous string functions
Ø Strrev() reversed
Ø Str_repeat
Ø Str_pad
Ø
n Decomposing s string
Ø Explode() return an array
Ø Implode() from an array
Ø Strtok()
Ø Sscanf() return an array, like printf
n Search
Ø strpos()
Ø strstr() return rest of string; strisstr() case-insensitive strrchr() last occurrence
Ø Strspn()
Ø Parse_url() return an array
Strings (Regular Expressions)
n Ignored
Arrays (Overview)
n Index versus associative
Ø Key => value
Ø Single quote
n Adding values to the End of Array
Ø $array[] = “value” append the value to a array
Ø Associative array has no this way
n Getting the Size of an Array
Ø Count()
Ø Sizeof()
n Padding an Array
Ø $array_pad($array,minvalue, initial value)
the second parameter can be a negative value
Arrays (Extracting Multiple Values)
n list
Ø List($m,$n,$o) = $array
Ø List($m,$n,,$o) = $array
n Slicing an Array
Ø Array_slice($array, $begin, $length) from 0
n Splitting an Array into Chunks
Ø Array_chunk($array, $size, optional)
one dimensional to two dimensional array
n Keys and Values
Ø $array_of_values()
Ø $array_of_keys()
n Checking Whether an Elment Exists
Ø $array_key_exists($key,$array)
n Removing and Inserting Elements in an Array
Ø $array_splice($array, start, length, replacement )
Arrays (Converting Between Arrays and Variables)
n Creating Vaiables from an Array
Ø Extract($array, ExTR_PREFIX_ALL, $prefix)
n Creating an Array from Variables
Ø Compact($variable…) associative array
Arrays (Traversing Arrays)
n The foreach Construct
Ø Foreach( $array as $value)
Ø Foreach( $array as $key=>value)
n The Iterator Functions
Ø Current()
Ø Reset()
Ø Next()
Ø Prev()
Ø End()
Ø Each()
Ø Key()
n Using for loop
Ø For()
n Calling a function for Each Array Element
Ø Array_walk($array, function_name)
n Reducing an Array
Ø Array_reduce()
n Searching an array
Ø In_array()
Arrays (Sorting)
n Sorting One Array at a Time
Ø Sort() rsort() usort() new from 0
Ø Asort() arsort() uasort()
Ø Ksort() krsort() uksort()
n Natural-Order Sorting
Ø Nassort()
Ø Natcasesort()
n Sorting Multiple Arrays at Once
Ø Array_multisort()
n Reversing Arrays
Ø Array_reverse()
Ø Array_flip() keys
n Randomizing Order
Ø Shuffle()
Arrays (Acting on entire arrays)
n Calculating the Sum of Array
Ø Array_sum()
n Merging Two Arrays
Ø Array_merge()
same key, the earlier value is replaced by the later value
n Filtering Elements from an Array
Ø array_filter( $array, callback)
each value is passed to the function, true is return, keys are preserved
n Sets
Ø Array_unique()
n Stacks
Ø Array_push()
Ø Array_pop()
Ø Array_shift()
Ø Array_unshift()