Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites
print("Your Name is $Name"); } else { print("I don't know your name"); } ?> boolean settype(variable, string type) The settyp ...
print(count($list)); print(" elements"); } ?> Arrays The functions in this section operate on arrays. Some of them sort the a ...
array array_flip(array data) The array_flip function returns the data argument with the indices and elements exchanged. Figure 9 ...
array array_keys(array data, string value) The array_keys function returns an array of the keys used in the data array. If the o ...
srand(time()); for($i=0; $i<10; $i++) { $data[] = rand(0,1); } //print out the keys to 1's foreach(array_keys($data, 1) as $k ...
The way array_multisort works is similar to the way a relational database sorts the results of a join. The first element of each ...
//create test data $data = array(1,2,3); //add "start" to beginning of array $data = array_pad($data, -4, "start"); //add "end" ...
//print out all the values //(red, blue, green, purple, yellow) print(""); print_r($colors); print("\n".); ?> array array_rev ...
array array_slice(array data, integer start, integer stop) The array_slice function returns part of an array, starting with the ...
Compare this function to array_merge and array_slice. <? function printElement($element) { print("$element\n"); } //set up an ...
array array_values(array data) The array_values function returns just the array elements, re-indexed with integers. <? //set ...
<? // build array $users = array("bob"=>"Robert", "steve"=>"Stephen", "jon"=>"Jonathon"); // sort array arsort($user ...
integer count(variable array) The count function returns the number of elements in an array. If the variable has never been set, ...
value current(array arrayname) The current function returns the value of the current element pointed to by PHP's internal pointe ...
print(current($colors)); ?> array explode(string delimiter, string data) The explode function creates an array from a string. ...
?> boolean in_array(value query, array data) The in_array function returns TRUE if the query argument is an element of the da ...
value key(array arrayname) The key function returns the index of the current element. Use current to find the value of the curre ...
$colors = array("red"=>"FF0000", "green"=>"00FF00", "blue"=>"0000FF"); // sort an array by its keys ksort($colors); // ...
//prints 13 print(max("hello", "55", 13). "\n"); //prints 17 print(max(1, 17, 3, 5.5). "\n"); ?> value min(array arrayname) v ...
pos You may use pos as an alias to the current function. value prev(array arrayname) The prev function operates similarly to the ...
«
7
8
9
10
11
12
13
14
15
16
»
Free download pdf