Presentation is loading. Please wait.

Presentation is loading. Please wait.

PhP Tutorial (3). Working with Arrays – Strings in PHP What is an Array.

Similar presentations


Presentation on theme: "PhP Tutorial (3). Working with Arrays – Strings in PHP What is an Array."— Presentation transcript:

1 PhP Tutorial (3)

2 Working with Arrays – Strings in PHP What is an Array

3 Working with Arrays – Strings in PHP Creating Associative Arrays

4 Working with Arrays – Strings in PHP Creating Multidimensional Arrays

5 Working with Arrays – Strings in PHP Looping or Iterating Over Arrays

6 Working with Arrays – Strings in PHP Array Functions Reference list FunctionDescription array_change_key_case()Change all key case array_chunk()Returns a multidimensional array of the chunked array array_combine() Combine two arrays, one array becomes the keys and the other the values array_count_values()Count values in an array array_diff()Evaluate the difference in arrays array_fill_keys()Specify keys of an array as it gets values put into it array_fill()Fill an array with values specifying starting index and fill value array_filter()Filters elements array_flip()Swap all keys with their values array_intersect()Evaluate the intersection of arrays array_key_exists()Checks if the given key or index exists array_keys()List all keys

7 Working with Arrays – Strings in PHP Array Functions Reference list FunctionDescription array_merge_recursive()Recursively merge elements from two or more arrays array_merge()Merge the elements from one or more arrays array_multisort()Sort multiple arrays array_pad()Pad an array to match a given length array_pop()Pop the last element off the end array_product()Get the product of values array_push()Add to the end of an array array_rand()Get random items from an array array_reduce()Reduce the array to a single value array_replace_recursive()Replace array data recursively array_replace()Replace array data array_reverse()Reverse an array array_search()Returns the key of values searched for and found in an array

8 Working with Arrays – Strings in PHP Array Functions Reference list FunctionDescription array_shift()Remove the first element in an array and return the value array_slice()Remove a specified element of an array array_splice()Replace a specified element of an array array_sum()Evaluate the sum of values in an array array_unique()Removes duplicate values from an array array_unshift()Add elements to the beginning of an array array_values()Return all the values of an array array_walk_recursive()Run a function recursively on every item of an array array_walk()Run a function on every item of an array arsort()Sort an array in reverse and maintain index association asort()Sort an array and maintain index association compact()Uses variable names as keys and their values as array values count()Count elements in an array

9 Working with Arrays – Strings in PHP Array Functions Reference list FunctionDescription current()Return the current element each()Return the current key value pair end()Move the internal pointer to the last element in an array extract()Create PHP variables with values from an array in_array()Checks if a value exists in an array key()Get a key from an array krsort()Sort an array by key in reverse order ksort()Sort an array by key list()Create a list of variables from an array natcasesort()Sort an array using a case insensitive natural order algorithm natsort()Sort an array using a natural order algorithm next()Move the internal pointer of an array ahead pos()See current() prev()Move the internal pointer of an array backward

10 Working with Arrays – Strings in PHP Array Functions Reference list FunctionDescription range() Returns an array made up of a range of elements from an original array reset()Move the internal pointer of an array to the first element rsort()Sort an array in reverse order shuffle()Randomly shuffle an array sizeof()See count() sort()Sort an array uasort()Sort an array with a user defined comparison uksort()Sort an array by keys with a user defined comparison usort()Sort an array by values with a user defined comparison

11 Working with Arrays – Strings in PHP Working With Strings and Numbers What is the string?? A string is any one or set of alphanumeric characters and spaces. E.g. Validate Email Addresses With PHP preg_match() and a Regex

12 Working with Arrays – Strings in PHP Selected String Functions String FunctionDescription addcslashes()Adds slashes to a string in C style chunk_split()Returns a string split into chunks count_chars()Count occurances of a target character in a string explode()Splits a string and returns an array of the parts

13 Assignments Run All functions List for: – Array function list – String Function List – Math Function List


Download ppt "PhP Tutorial (3). Working with Arrays – Strings in PHP What is an Array."

Similar presentations


Ads by Google