SlideShare ist ein Scribd-Unternehmen logo
1 von 636
IntelliBitz Technologies Training Division 168, Medavakkam Main Road Madipakkam, Chennai 91. PH: +91 044 2247 5106 www.intellibitz.com [email_address]
PHP WEB  PROGRAMMING.
CHAPTER 1 STARTING WITH PHP.
PHP First Steps - Overview ,[object Object],[object Object],[object Object],[object Object],[object Object]
PHP and the Web ,[object Object],[object Object],[object Object]
PHP and the Web ,[object Object],[object Object],[object Object]
PHP and the Web ,[object Object],[object Object]
PHP – a server-side language ,[object Object],[object Object],[object Object]
What's So Great About PHP? ,[object Object],[object Object],[object Object],[object Object],[object Object]
PHP in action ,[object Object],[object Object],[object Object],[object Object],[object Object]
Basic Rules of PHP Programs ,[object Object],[object Object],[object Object]
Chapter Summary ,[object Object],[object Object],[object Object],[object Object]
CHAPTER 2 TEXT AND NUMBERS
Working with Text and Numbers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Text ,[object Object],[object Object],[object Object],[object Object],[object Object]
Defining Text Strings ,[object Object],[object Object],[object Object]
Manipulating Text ,[object Object],[object Object],[object Object]
Formatting Text ,[object Object],[object Object],[object Object]
String Functions. ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String Functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions. ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions. ,[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Type specifiers  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Numbers ,[object Object],[object Object],[object Object],[object Object],[object Object]
Variables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Operating on Variables ,[object Object],[object Object],[object Object],[object Object]
Number functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Number functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Number functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Number functions ,[object Object],[object Object],[object Object],[object Object]
Number functions ,[object Object],[object Object],[object Object],[object Object]
Number functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Number functions ,[object Object],[object Object]
Chapter Summary ,[object Object],[object Object],[object Object],[object Object]
Chapter Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Chapter Summary ,[object Object],[object Object],[object Object],[object Object]
CHAPTER 3 Making Decisions and Looping
Making Decisions and Looping ,[object Object],[object Object],[object Object],[object Object]
Understanding true and false ,[object Object],[object Object],[object Object],[object Object]
Control statements ,[object Object],[object Object],[object Object],[object Object],[object Object]
Making Decisions ,[object Object],[object Object],[object Object],[object Object]
If statement ,[object Object],[object Object],[object Object],if (expr) statement
If statements ,[object Object],[object Object],[object Object],<?php if ($a > $b)     echo &quot;a is bigger than b&quot;; ?>  <?php if ($a > $b) {     echo &quot;a is bigger than b&quot;;     $b = $a; } ?>
If else statement ,[object Object],[object Object],[object Object],<?php if ($a > $b) {     echo &quot;a is bigger than b&quot;; } else {     echo &quot;a is NOT bigger than b&quot;; } ?>
else if ,[object Object],[object Object],[object Object],<?php if ($a > $b) {     echo &quot;a is bigger than b&quot;; } elseif ($a == $b) {     echo &quot;a is equal to b&quot;; } else {     echo &quot;a is smaller than b&quot;; } ?>
elseif statement ,[object Object],[object Object],[object Object]
while()  ,[object Object],[object Object],[object Object],while (expr) statement <?php $i = 1; while ($i <= 10) {     echo $i++;   } /* the printed value would be $i before the increment (post-increment) */ ?>
do while ,[object Object],[object Object],[object Object],<?php $i = 0; do {     echo $i; } while ($i > 0); ?>
for statement ,[object Object],[object Object],[object Object],for (initialise;  test condition;  increment value) statement for ($i = 1; $i <= 10; $i++) {   echo $i; } for ($i = 1; ; $i++) { if ($i > 10) { break; } echo $i; }
for loop ,[object Object],[object Object],[object Object],$i = 1; for (; ; ) {     if ($i > 10) {         break;     }     echo $i;     $i++; } for ($i = 1, $j = 0; $i <= 10; $j += $i, print $i, $i++);
foreach loop ,[object Object],[object Object],[object Object],[object Object],foreach (array_expression as $value) statement foreach (array_expression as $key => $value) statement
foreach ,[object Object],[object Object],[object Object],<?php $arr = array(1, 2, 3, 4); foreach ($arr as &$value) {     $value = $value * 2; } // $arr is now array(2, 4, 6, 8) foreach($arr as $key =>$val){ print”$key=$val”; } ?>
foreach ,[object Object],[object Object]
break ,[object Object],[object Object],$i = 0;  while (++$i) {     switch ($i) {     case 5:         echo &quot;At 5<br />&quot;;         break 1;  /* Exit only the switch. */     case 10:         echo &quot;At 10; quitting<br />&quot;;         break 2;  /* Exit the switch and the while. */     default:         break;     } }
continue ,[object Object],[object Object],[object Object],$i = 0; while ($i++ < 5) {     echo &quot;Outer<br />&quot;;     while (1) {         echo &quot;Middle<br />&quot;;         while (1) {             echo &quot;Inner<br />&quot;;             continue 3;         }    echo &quot;This never gets output.<br />&quot;;     }     echo &quot;Neither does this.<br />&quot;; }
switch ,[object Object],[object Object],<?php switch ($i) { case 0:     echo &quot;i equals 0&quot;;     break; case 1:     echo &quot;i equals 1&quot;;     break; case 2:     echo &quot;i equals 2&quot;;     break; } ?>
switch ,[object Object],[object Object],[object Object],[object Object],?php switch ($i) { case 0:     echo &quot;i equals 0&quot;; case 1:     echo &quot;i equals 1&quot;; case 2:     echo &quot;i equals 2&quot;; } ?>
Alternative syntax ,[object Object],<?php if ($a == 5): ?> A is equal to 5 <?php endif; ?>  <?php if ($a == 5):     echo &quot;a equals 5&quot;;     echo &quot;...&quot;; elseif ($a == 6):     echo &quot;a equals 6&quot;;     echo &quot;!!!&quot;; else:     echo &quot;a is neither 5 nor 6&quot;; endif; ?>
return ,[object Object],[object Object],[object Object]
return ,[object Object],[object Object]
require() ,[object Object],[object Object],<?php require 'prepend.php'; require $somefile; require ('somefile.txt'); ?>
include() ,[object Object],[object Object],[object Object],[object Object],[object Object]
require_once() ,[object Object],[object Object]
require_once() ,[object Object],<?php require_once(&quot;a.php&quot;); // this will include a.php require_once(&quot;A.php&quot;); // this will include a.php //again on Windows! (PHP 4 only) ?>
include_once() ,[object Object]
declare ,[object Object],[object Object],[object Object],[object Object],declare (directive) statement <?php // these are the same: // you can use this: declare(ticks=1) {     // entire script here } // or you can use this: declare(ticks=1); // entire script here ?>
ticks ,[object Object],[object Object],[object Object]
ticks <?php // A function that records the time when it is called function profile($dump = FALSE) {     static $profile;     // Return the times stored in profile, then erase it     if ($dump) {         $temp = $profile;         unset($profile);         return $temp;     } $profile[] = microtime(); } // Set up a tick handler register_tick_function(&quot;profile&quot;); // Initialize the function before the declare block profile(); // Run a block of code, throw a tick every  2nd statement declare(ticks=2) {   for ($x = 1; $x < 50; ++$x) { echo similar_text(md5($x), md5($x*$x)), &quot;<br />;&quot;;     } } // Display the data stored in the profiler print_r(profile(TRUE)); ?>
Building Complicated Decisions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Repeating Yourself ,[object Object],[object Object],[object Object]
Chapter Summary ,[object Object],[object Object],[object Object],[object Object],[object Object]
Chapter Summary ,[object Object],[object Object],[object Object]
Chapter Summary ,[object Object],[object Object],[object Object],[object Object]
Chapter Summary ,[object Object],[object Object],[object Object]
CHAPTER 4 WORKING WITH ARRAYS
Working with Arrays ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Array Basics and Creation ,[object Object],[object Object],[object Object]
Creating an Array ,[object Object],[object Object],[object Object],[object Object]
Creating a Numeric Array ,[object Object],[object Object],[object Object],[object Object]
Looping through Arrays ,[object Object],[object Object],[object Object],[object Object]
Looping through Arrays ,[object Object],[object Object],[object Object],[object Object]
array() ,[object Object],[object Object],[object Object],<?php $fruits = array (     &quot;fruits&quot;  => array(&quot;a&quot; => &quot;orange&quot;, &quot;b&quot; => &quot;banana&quot;, &quot;c&quot; => &quot;apple&quot;),     &quot;numbers&quot; => array(1, 2, 3, 4, 5, 6),     &quot;holes&quot;  => array(&quot;first&quot;, 5 => &quot;second&quot;, &quot;third&quot;) ); ?>
array <?php $array = array(1, 1, 1, 1,  1, 8 => 1,  4 => 1, 19, 3 => 13); print_r($array); ?>  Array (     [0] => 1     [1] => 1     [2] => 1     [3] => 13     [4] => 1     [8] => 1     [9] => 19 )
array() <?php $firstquarter = array(1 => 'January', 'February', 'March'); print_r($firstquarter); ?>  The above example will output: Array ( [1] => January [2] => February [3] => March ) 1-based index with array() <?php $foo = array('bar' => 'baz'); echo &quot;Hello {$foo['bar']}!&quot;; // Hello baz! ?>
sort ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],<?php $fruits = array(&quot;lemon&quot;, &quot;orange&quot;, &quot;banana&quot;, &quot;apple&quot;); sort($fruits); foreach ($fruits as $key => $val) {     echo &quot;fruits[&quot; . $key . &quot;] = &quot; . $val . &quot;&quot;; } ?>  The above example will output: fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange
rsort ,[object Object],[object Object],[object Object],[object Object],[object Object]
rsort <?php $fruits = array(&quot;lemon&quot;, &quot;orange&quot;, &quot;banana&quot;, &quot;apple&quot;); rsort($fruits); foreach ($fruits as $key => $val) {     echo &quot;$key = $val&quot;; } ?>  The above example will output: 0 = orange 1 = lemon 2 = banana 3 = apple
asort ,[object Object],[object Object],[object Object],[object Object]
asort <?php $fruits = array(&quot;d&quot; => &quot;lemon&quot;, &quot;a&quot; => &quot;orange&quot;, &quot;b&quot; => &quot;banana&quot;, &quot;c&quot; => &quot;apple&quot;); asort($fruits); foreach ($fruits as $key => $val) {     echo &quot;$key = $val&quot;; } ?>  The above example will output: c = apple b = banana d = lemon a = orange The fruits have been sorted in alphabetical order, and the index associated with each element has been maintained.
arsort ,[object Object],[object Object],[object Object],[object Object]
arsort <?php $fruits = array(&quot;d&quot; => &quot;lemon&quot;, &quot;a&quot; => &quot;orange&quot;, &quot;b&quot; => &quot;banana&quot;, &quot;c&quot; => &quot;apple&quot;); arsort($fruits); foreach ($fruits as $key => $val) {     echo &quot;$key = $val&quot;; } ?>  The above example will output: a = orange d = lemon b = banana c = apple The fruits have been sorted in reverse alphabetical order, and the index associated with each element has been maintained.
ksort ,[object Object],[object Object],[object Object],[object Object],<?php $fruits = array(&quot;d&quot;=>&quot;lemon&quot;, &quot;a&quot;=>&quot;orange&quot;, &quot;b&quot;=>&quot;banana&quot;, &quot;c&quot;=>&quot;apple&quot;); ksort($fruits); foreach ($fruits as $key => $val) {     echo &quot;$key = $val&quot;; } ?>  The above example will output: a = orange b = banana c = apple d = lemon
krsort ,[object Object],[object Object],[object Object],[object Object],<?php $fruits = array(&quot;d&quot;=>&quot;lemon&quot;, &quot;a&quot;=>&quot;orange&quot;, &quot;b&quot;=>&quot;banana&quot;, &quot;c&quot;=>&quot;apple&quot;); krsort($fruits); foreach ($fruits as $key => $val) {     echo &quot;$key = $val&quot;; } ?>  The above example will output: d = lemon c = apple b = banana a = orange
natsort ,[object Object],[object Object],[object Object],[object Object],[object Object]
natsort <?php $array1 = $array2 = array(&quot;img12.png&quot;, &quot;img10.png&quot;, &quot;img2.png&quot;, &quot;img1.png&quot;); sort($array1); echo &quot;Standard sorting&quot;; print_r($array1); natsort($array2); echo &quot;Natural order sorting&quot;; print_r($array2); ?>  The above example will output: Standard sorting Array ( [0] => img1.png [1] => img10.png [2] => img12.png [3] => img2.png ) Natural order sorting Array ( [3] => img1.png [2] => img2.png [1] => img10.png [0] => img12.png )
usort ,[object Object],[object Object],[object Object],[object Object],[object Object]
usort <?php function cmp($a, $b) {     if ($a == $b) {         return 0;     }     return ($a < $b) ? -1 : 1; } $a = array(3, 2, 5, 6, 1); usort($a, &quot;cmp&quot;); foreach ($a as $key => $value) {     echo &quot;$key: $value&quot;; } ?>  The above example will output: 0: 1 1: 2 2: 3 3: 5 4: 6
usort ,[object Object],[object Object],[object Object]
uasort ,[object Object],[object Object],[object Object],[object Object]
uksort ,[object Object],[object Object],[object Object],[object Object],[object Object]
uksort <?php function cmp($a, $b) {     $a = ereg_replace('^(a|an|the) ', '', $a);     $b = ereg_replace('^(a|an|the) ', '', $b);     return strcasecmp($a, $b); } The above example will output: an apple: 3 a banana: 4 the Earth: 2 John: 1 $a = array(&quot;John&quot; => 1, &quot;the Earth&quot; => 2, &quot;an apple&quot; => 3, &quot;a banana&quot; => 4); uksort($a, &quot;cmp&quot;); foreach ($a as $key => $value) {     echo &quot;$key: $value&quot;; } ?>
list ,[object Object],[object Object],[object Object],[object Object],<?php $info = array('coffee', 'brown', 'caffeine'); // Listing all the variables list($drink, $color, $power) = $info; echo &quot;$drink is $color and $power makes it special.&quot;; // Listing some of them list($drink, , $power) = $info; echo &quot;$drink has $power.&quot;; // Or let's skip to only the third one list( , , $power) = $info; echo &quot;I need $power!&quot;; ?>
shuffle ,[object Object],[object Object],[object Object],<?php $numbers = range(1, 20); shuffle($numbers); foreach ($numbers as $number) {     echo &quot;$number &quot;; } ?>
array_change_key_case ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],<?php $input_array = array(&quot;FirSt&quot; => 1, &quot;SecOnd&quot; => 4); print_r(array_change_key_case($input_array, CASE_UPPER)); ?>  The above example will output: Array ( [FIRST] => 1 [SECOND] => 4 )
array_chunk() ,[object Object],[object Object],[object Object],<?php $input_array = array('a', 'b', 'c', 'd', 'e'); print_r(array_chunk($input_array, 2)); ?>  The below example will output: Array ( [0] => Array ( [0] => a [1] => b ) [1] => Array ( [0] => c [1] => d ) [2] => Array ( [0] => e ) )
array_chunk() ,[object Object],[object Object],<?php $input_array = array('a', 'b', 'c', 'd', 'e'); print_r(array_chunk($input_array, 2, true)); ?>  The below example will output: Array ( [0] => Array ( [0] => a [1] => b ) [1] => Array ( [2] => c [3] => d ) [2] => Array ( [4] => e ) )
key ,[object Object],[object Object],[object Object],<?php $array = array(     'fruit1' => 'apple',     'fruit2' => 'orange',     'fruit3' => 'grape',     'fruit4' => 'apple',     'fruit5' => 'apple'); / / this cycle echoes all associative array // key where value equals &quot;apple&quot; while ($fruit_name = current($array)) {     if ($fruit_name == 'apple') {         echo key($array).'<br />';     }     next($array); } ?>
count ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
count <?php $a[0] = 1; $a[1] = 3; $a[2] = 5; $result = count($a); // $result == 3 $b[0]  = 7; $b[5]  = 9; $b[10] = 11; $result = count($b); // $result == 3 $result = count(null); // $result == 0 $result = count(false); // $result == 1 ?>  sizeof — Alias of count()
current ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
next ,[object Object],[object Object],[object Object],[object Object],<?php $transport = array('foot', 'bike', 'car', 'plane'); $mode = current($transport); // $mode = 'foot'; $mode = next($transport);    // $mode = 'bike'; $mode = next($transport);    // $mode = 'car'; $mode = prev($transport);    // $mode = 'bike'; $mode = end($transport);    // $mode = 'plane'; ?>
prev ,[object Object],[object Object],[object Object],<?php $transport = array('foot', 'bike', 'car', 'plane'); $mode = current($transport); // $mode = 'foot'; $mode = next($transport);    // $mode = 'bike'; $mode = next($transport);    // $mode = 'car'; $mode = prev($transport);    // $mode = 'bike'; $mode = end($transport);    // $mode = 'plane'; ?>
each ,[object Object],[object Object],[object Object],[object Object],[object Object]
each <?php $foo = array(&quot;bob&quot;, &quot;fred&quot;, &quot;jussi&quot;, &quot;jouni&quot;, &quot;egon&quot;, &quot;marliese&quot;); $bar = each($foo); print_r($bar); ?>  $bar now contains the following key/value pairs:  Array ( [1] => bob [value] => bob [0] => 0 [key] => 0 ) <?php $foo = array(&quot;Robert&quot; => &quot;Bob&quot;, &quot;Seppo&quot; => &quot;Sepi&quot;); $bar = each($foo); print_r($bar); ?>  $bar now contains the following key/value pairs:  Array ( [1] => Bob [value] => Bob [0] => Robert [key] => Robert )
end ,[object Object],[object Object],[object Object],<?php $fruits = array('apple', 'banana', 'cranberry'); echo end($fruits); // cranberry ?>
reset ,[object Object],[object Object],[object Object]
reset <?php $array = array('step one', 'step two', 'step three', 'step four'); // by default, the pointer is on the first element echo current($array) . &quot;<br />&quot;; // &quot;step one&quot; // skip two steps next($array); next($array); echo current($array) . &quot;<br />&quot;; // &quot;step three&quot; // reset pointer, start again on step one reset($array); echo current($array) . &quot;<br />&quot;; // &quot;step one&quot; ?>
range ,[object Object],[object Object],[object Object],[object Object],[object Object]
range // array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'); foreach (range('a', 'i') as $letter) {     echo $letter; } // array('c', 'b', 'a'); foreach (range('c', 'a') as $letter) {     echo $letter; } ?> ?php // array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) foreach (range(0, 12) as $number) {     echo $number; } // The step parameter was introduced in 5.0.0 // array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100) foreach (range(0, 100, 10) as $number) {     echo $number; }
in_array() ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
in_array <?php $os = array(&quot;Mac&quot;, &quot;NT&quot;, &quot;Irix&quot;, &quot;Linux&quot;); if (in_array(&quot;Irix&quot;, $os)) {     echo &quot;Got Irix&quot;; } if (in_array(&quot;mac&quot;, $os)) {     echo &quot;Got mac&quot;; } ?>  The second condition fails because in_array() is case-sensitive, so the program above will display:  Got Irix
extract ,[object Object],[object Object],[object Object]
array_count_values ,[object Object],[object Object],[object Object],<?php $array = array(1, &quot;hello&quot;, 1, &quot;world&quot;, &quot;hello&quot;); print_r(array_count_values($array)); ?>  The above example will output: Array ( [1] => 2 [hello] => 2 [world] => 1 )
array_sum ,[object Object],[object Object],[object Object],<?php $a = array(2, 4, 6, 8); echo &quot;sum(a) = &quot; . array_sum($a) . &quot;&quot;; $b = array(&quot;a&quot; => 1.2, &quot;b&quot; => 2.3, &quot;c&quot; => 3.4); echo &quot;sum(b) = &quot; . array_sum($b) . &quot;&quot;; ?>  The above example will output: sum(a) = 20 sum(b) = 6.9
array_values ,[object Object],[object Object],[object Object],<?php $array = array(&quot;size&quot; => &quot;XL&quot;, &quot;color&quot; => &quot;gold&quot;); print_r(array_values($array)); ?>  The above example will output: Array (     [0] => XL     [1] => gold )
array_pad ,[object Object],[object Object],[object Object],<?php $input = array(12, 10, 9); $result = array_pad($input, 5, 0); // result is array(12, 10, 9, 0, 0) $result = array_pad($input, -7, -1); // result is array(-1, -1, -1, -1, 12, 10, 9) $result = array_pad($input, 2, &quot;noop&quot;); // not padded ?>  www.intellibitz.com   [email_address]
array_pop ,[object Object],[object Object],[object Object],<?php $stack = array(&quot;orange&quot;, &quot;banana&quot;, &quot;apple&quot;, &quot;raspberry&quot;); $fruit = array_pop($stack); print_r($stack); ?>  After this, $stack will have only 3 elements:  Array (     [0] => orange     [1] => banana     [2] => apple ) and raspberry will be assigned to $fruit.
array_push ,[object Object],[object Object],[object Object],<?php $stack = array(&quot;orange&quot;, &quot;banana&quot;); array_push($stack, &quot;apple&quot;, &quot;raspberry&quot;); print_r($stack); ?>  The above example will output: Array (     [0] => orange     [1] => banana     [2] => apple     [3] => raspberry )
array_push ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
compact ,[object Object],[object Object],[object Object],[object Object],[object Object]
array_product ,[object Object],[object Object],[object Object],<?php $a = array(2, 4, 6, 8); echo &quot;product(a) = &quot; . array_product($a) . &quot;&quot;; ?>  The above example will output: product(a) = 384
array_rand ,[object Object],[object Object],[object Object],[object Object],<?php $input = array(&quot;Neo&quot;, &quot;Morpheus&quot;, &quot;Trinity&quot;, &quot;Cypher&quot;, &quot;Tank&quot;); $rand_keys = array_rand($input, 2); echo $input[$rand_keys[0]] . &quot;&quot;; echo $input[$rand_keys[1]] . &quot;&quot;; ?>
array_walk ,[object Object],[object Object],[object Object],[object Object]
array_walk <?php $fruits = array(&quot;d&quot; => &quot;lemon&quot;, &quot;a&quot; => &quot;orange&quot;, &quot;b&quot; => &quot;banana&quot;, &quot;c&quot; => &quot;apple&quot;); function test_alter(&$item1, $key, $prefix) {     $item1 = &quot;$prefix: $item1&quot;; } function test_print($item2, $key) {     echo &quot;$key. $item2<br />&quot;; } This example will output: Before ...: d. lemon a. orange b. banana c. apple ... and after: d. fruit: lemon a. fruit: orange b. fruit: banana c. fruit: apple  echo &quot;Before ...:&quot;; array_walk($fruits, 'test_print'); array_walk($fruits, 'test_alter', 'fruit'); echo &quot;... and after:&quot;; array_walk($fruits, 'test_print'); ?>
array_unique ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
array_unique <?php $input = array(&quot;a&quot; => &quot;green&quot;, &quot;red&quot;, &quot;b&quot; => &quot;green&quot;, &quot;blue&quot;, &quot;red&quot;); $result = array_unique($input); print_r($result); ?>  The above example will output: Array (     [a] => green     [0] => red     [1] => blue )  <?php $input = array(4, &quot;4&quot;, &quot;3&quot;, 4, 3, &quot;3&quot;); $result = array_unique($input); var_dump($result); ?>  The above example will output: array(2) {    [0] => int(4)    [2] => string(1) &quot;3&quot; }
array_map ,[object Object],[object Object],[object Object],?php function cube($n) {     return($n * $n * $n); } $a = array(1, 2, 3, 4, 5); $b = array_map(&quot;cube&quot;, $a); print_r($b); ?>  This makes $b have:  Array ( [0] => 1 [1] => 8 [2] => 27 [3] => 64 [4] => 125 )
array_reduce ,[object Object],[object Object],<?php function rsum($v, $w) {     $v += $w;     return $v; } $a = array(1, 2, 3, 4, 5); $x = array(); $b = array_reduce($a, &quot;rsum&quot;); $c = array_reduce($a, &quot;rmul&quot;, 10); $d = array_reduce($x, &quot;rsum&quot;, 1); ?>  This will result in $b containing 15, $c containing 1200 (= 10*1*2*3*4*5), and $d containing 1.  function rmul($v, $w) {     $v *= $w;     return $v; }
array_reduce ,[object Object],[object Object],[object Object]
array_reverse ,[object Object],[object Object],[object Object]
array_reverse <?php $input  = array(&quot;php&quot;, 4.0, array(&quot;green&quot;, &quot;red&quot;)); $result = array_reverse($input); $result_keyed = array_reverse($input, true); ?>  Array (     [2] => Array         (             [0] => green             [1] => red         )     [1] => 4     [0] => php )  Array (     [0] => Array         (             [0] => green             [1] => red         )     [1] => 4     [2] => php ) $result will be $result_keyed will be:  This makes both $result and $result_keyed have the same elements, but note the difference between the keys.
array_search ,[object Object],[object Object],[object Object],[object Object],[object Object],<?php $array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red'); $key = array_search('green', $array); // $key = 2; $key = array_search('red', $array);  // $key = 1; ?>
array_shift ,[object Object],[object Object],[object Object],[object Object],[object Object]
array_shift <?php $stack = array(&quot;orange&quot;, &quot;banana&quot;, &quot;apple&quot;, &quot;raspberry&quot;); $fruit = array_shift($stack); print_r($stack); ?>  This would result in $stack having 3 elements left:  Array (     [0] => banana     [1] => apple     [2] => raspberry )  and orange will be assigned to $fruit.
array_unshift ,[object Object],[object Object],[object Object],[object Object],<?php $queue = array(&quot;orange&quot;, &quot;banana&quot;); array_unshift($queue, &quot;apple&quot;, &quot;raspberry&quot;); print_r($queue); ?>  The above example will output: Array (     [0] => apple     [1] => raspberry     [2] => orange     [3] => banana )
array_slice ,[object Object],[object Object],[object Object]
array_slice ,[object Object],[object Object]
array_slice <?php $input = array(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;); $output = array_slice($input, 2);      // returns &quot;c&quot;, &quot;d&quot;, and &quot;e&quot; $output = array_slice($input, -2, 1);  // returns &quot;d&quot; $output = array_slice($input, 0, 3);  // returns &quot;a&quot;, &quot;b&quot;, and &quot;c&quot; // note the differences in the array keys print_r(array_slice($input, 2, -1)); print_r(array_slice($input, 2, -1, true)); Array ( [0] => c [1] => d ) Array ( [2] => c [3] => d )
array_splice ,[object Object],[object Object],<?php $input = array(&quot;red&quot;, &quot;green&quot;, &quot;blue&quot;, &quot;yellow&quot;); array_splice($input, 2); // $input is now array(&quot;red&quot;, &quot;green&quot;) $input = array(&quot;red&quot;, &quot;green&quot;, &quot;blue&quot;, &quot;yellow&quot;); array_splice($input, 1, -1); // $input is now array(&quot;red&quot;, &quot;yellow&quot;)
array_splice ,[object Object],[object Object],[object Object],[object Object]
array_merge ,[object Object],[object Object],[object Object],<?php $array1 = array( &quot;color&quot; => &quot;red&quot;, 2, 4); $array2 = array( &quot;a&quot;, &quot;b&quot;,  &quot;color&quot; => &quot;green&quot;, &quot;shape&quot; => &quot;trapezoid&quot;,4); $result = array_merge($array1, $array2); print_r($result); ?>  This example will output: Array (     [color] => green     [0] => 2     [1] => 4     [2] => a     [3] => b     [shape] => trapezoid     [4] => 4 )
array_merge_recursive ,[object Object],<?php $ar1 = array(&quot;color&quot; =>  array(&quot;favorite&quot; => &quot;red&quot;), 5); $ar2 = array(10, &quot;color&quot; => array(&quot;favorite&quot; => &quot;green&quot;, &quot;blue&quot;)); $result = array_merge_recursive($ar1, $ar2); print_r($result); ?>  Array (     [color] => Array         (             [favorite] => Array                 (                     [0] => red                     [1] => green                 )             [0] => blue   )    [0] => 5     [1] => 10 )
array_key ,[object Object],[object Object],[object Object],[object Object]
array_key <?php $array = array(0 => 100, &quot;color&quot; => &quot;red&quot;); print_r(array_keys($array)); $array = array(&quot;blue&quot;, &quot;red&quot;, &quot;green&quot;, &quot;blue&quot;, &quot;blue&quot;); print_r(array_keys($array, &quot;blue&quot;)); $array = array(&quot;color&quot; => array(&quot;blue&quot;, &quot;red&quot;, &quot;green&quot;),                 &quot;size&quot;  => array(&quot;small&quot;, &quot;medium&quot;, &quot;large&quot;)); print_r(array_keys($array)); ?>  The above example will output: Array ( [0] => 0 [1] => color ) Array ( [0] => 0 [1] => 3 [2] => 4 ) Array ( [0] => color [1] => size )
array_key_exists ,[object Object],[object Object],[object Object],<?php $search_array = array('first' => 1, 'second' => 4); if (array_key_exists('first', $search_array)) {     echo &quot;The 'first' element is in the array&quot;; } ?>  <?php $search_array = array('first' => null, 'second' =>  4); // returns false isset($search_array['first']); // returns true array_key_exists('first', $search_array); ?>
array_fill ,[object Object],[object Object],[object Object],?php $a = array_fill(5, 6, 'banana'); print_r($a); ?>  $a now is:  Array ( [5]  => banana [6]  => banana [7]  => banana [8]  => banana [9]  => banana [10] => banana )
array_fill_keys ,[object Object],[object Object],[object Object],<?php $keys = array('foo', 5, 10, 'bar'); $a = array_fill_keys($keys, 'banana'); print_r($a); ?>  $a now is:  Array ( [foo] => banana [5] => banana [10] => banana [bar] => banana )
array_flip ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],<?php $trans = array(&quot;a&quot; => 1, &quot;b&quot; => 1, &quot;c&quot;  => 2); $trans = array_flip($trans); print_r($trans); ?>  now $trans is:  Array ( [1] => b [2] => c )
array_intersect ,[object Object],[object Object],[object Object],[object Object],<?php $array1 = array(&quot;a&quot; => &quot;green&quot;, &quot;red&quot;, &quot;blue&quot;); $array2 = array(&quot;b&quot; => &quot;green&quot;, &quot;yellow&quot;, &quot;red&quot;); $result = array_intersect($array1, $array2); print_r($result); ?>  The above example will output: Array (     [a] => green     [0] => red )
array_intersect_key ,[object Object],[object Object],[object Object]
array_intersect_key ,[object Object],[object Object],<?php $array1 = array('blue'  => 1, 'red'  => 2, 'green'  => 3, 'purple' => 4); $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan'  => 8); var_dump(array_intersect_key($array1, $array2)); ?>  The above example will output: array(2) { [&quot;blue&quot;]=> int(1) [&quot;green&quot;]=> int(3) }
array_intersect_uassoc ,[object Object],[object Object],[object Object],[object Object],<?php $array1 = array(&quot;a&quot; => &quot;green&quot;, &quot;b&quot; => &quot;brown&quot;, &quot;c&quot; => &quot;blue&quot;, &quot;red&quot;); $array2 = array(&quot;a&quot; => &quot;GREEN&quot;, &quot;B&quot; => &quot;brown&quot;, &quot;yellow&quot;, &quot;red&quot;); print_r(array_intersect_uassoc($array1, $array2, &quot;strcasecmp&quot;)); ?>  The above example will output: Array ( [b] => brown )
array_intersect_assoc ,[object Object],[object Object],[object Object],<?php $array1 = array(&quot;a&quot; => &quot;green&quot;, &quot;b&quot; => &quot;brown&quot;, &quot;c&quot; => &quot;blue&quot;, &quot;red&quot;); $array2 = array(&quot;a&quot; => &quot;green&quot;, &quot;yellow&quot;, &quot;red&quot;); $result_array = array_intersect_assoc($array1, $array2); print_r($result_array); ?>  The above example will output: Array ( [a] => green )
array_intersect_assoc ,[object Object],[object Object]
array_intersect_ukey ,[object Object],[object Object],[object Object],[object Object]
array_intersect_ukey <?php function key_compare_func($key1, $key2) {     if ($key1 == $key2)         return 0;     else if ($key1 > $key2)         return 1;     else         return -1; } The above example will output: array(2) { [&quot;blue&quot;]=> int(1) [&quot;green&quot;]=> int(3) } $array1 = array('blue'  => 1, 'red'  => 2, 'gree
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming
PHP Web Programming

Weitere ähnliche Inhalte

Was ist angesagt?

Php Using Arrays
Php Using ArraysPhp Using Arrays
Php Using Arrays
mussawir20
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
Arjun Shanka
 

Was ist angesagt? (20)

Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04
 
Php Lecture Notes
Php Lecture NotesPhp Lecture Notes
Php Lecture Notes
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Php Using Arrays
Php Using ArraysPhp Using Arrays
Php Using Arrays
 
javaScript.ppt
javaScript.pptjavaScript.ppt
javaScript.ppt
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Python basic
Python basicPython basic
Python basic
 
Javascript
JavascriptJavascript
Javascript
 
HTML
HTMLHTML
HTML
 
3.2 javascript regex
3.2 javascript regex3.2 javascript regex
3.2 javascript regex
 
Python final ppt
Python final pptPython final ppt
Python final ppt
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
 
Php pattern matching
Php pattern matchingPhp pattern matching
Php pattern matching
 
Database Connectivity in PHP
Database Connectivity in PHPDatabase Connectivity in PHP
Database Connectivity in PHP
 

Andere mochten auch

Beginners PHP Tutorial
Beginners PHP TutorialBeginners PHP Tutorial
Beginners PHP Tutorial
alexjones89
 
Php & mysql course syllabus
Php & mysql course syllabusPhp & mysql course syllabus
Php & mysql course syllabus
Papitha Velumani
 
Top 100 PHP Questions and Answers
Top 100 PHP Questions and AnswersTop 100 PHP Questions and Answers
Top 100 PHP Questions and Answers
iimjobs and hirist
 
Web Server Programming - Chapter 1
Web Server Programming - Chapter 1Web Server Programming - Chapter 1
Web Server Programming - Chapter 1
Nicole Ryan
 
HTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPCHTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPC
Mayflower GmbH
 
Advanced PHP: Design Patterns - Dennis-Jan Broerse
Advanced PHP: Design Patterns - Dennis-Jan BroerseAdvanced PHP: Design Patterns - Dennis-Jan Broerse
Advanced PHP: Design Patterns - Dennis-Jan Broerse
dpc
 

Andere mochten auch (20)

PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
 
Beginners PHP Tutorial
Beginners PHP TutorialBeginners PHP Tutorial
Beginners PHP Tutorial
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Php Ppt
Php PptPhp Ppt
Php Ppt
 
Class 6 - PHP Web Programming
Class 6 - PHP Web ProgrammingClass 6 - PHP Web Programming
Class 6 - PHP Web Programming
 
Php & mysql course syllabus
Php & mysql course syllabusPhp & mysql course syllabus
Php & mysql course syllabus
 
Top 100 PHP Questions and Answers
Top 100 PHP Questions and AnswersTop 100 PHP Questions and Answers
Top 100 PHP Questions and Answers
 
Web Server Programming - Chapter 1
Web Server Programming - Chapter 1Web Server Programming - Chapter 1
Web Server Programming - Chapter 1
 
PHP MySQL Workshop - facehook
PHP MySQL Workshop - facehookPHP MySQL Workshop - facehook
PHP MySQL Workshop - facehook
 
HTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPCHTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPC
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
Introduction to Bootstrap
Introduction to BootstrapIntroduction to Bootstrap
Introduction to Bootstrap
 
Php Security By Mugdha And Anish
Php Security By Mugdha And AnishPhp Security By Mugdha And Anish
Php Security By Mugdha And Anish
 
Advanced Php - Macq Electronique 2010
Advanced Php - Macq Electronique 2010Advanced Php - Macq Electronique 2010
Advanced Php - Macq Electronique 2010
 
Curs2 poo 2016
Curs2 poo 2016Curs2 poo 2016
Curs2 poo 2016
 
Curs1 poo 2016
Curs1 poo 2016Curs1 poo 2016
Curs1 poo 2016
 
Introduction to php web programming - sessions and cookies
Introduction to php   web programming - sessions and cookiesIntroduction to php   web programming - sessions and cookies
Introduction to php web programming - sessions and cookies
 
Advanced PHP: Design Patterns - Dennis-Jan Broerse
Advanced PHP: Design Patterns - Dennis-Jan BroerseAdvanced PHP: Design Patterns - Dennis-Jan Broerse
Advanced PHP: Design Patterns - Dennis-Jan Broerse
 
Bootstrap 3 - Sleek, intuitive, and powerful mobile first front-end framework...
Bootstrap 3 - Sleek, intuitive, and powerful mobile first front-end framework...Bootstrap 3 - Sleek, intuitive, and powerful mobile first front-end framework...
Bootstrap 3 - Sleek, intuitive, and powerful mobile first front-end framework...
 
Bootstrap ppt
Bootstrap pptBootstrap ppt
Bootstrap ppt
 

Ähnlich wie PHP Web Programming

String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering CollegeString handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
Dhivyaa C.R
 
Manipulating strings
Manipulating stringsManipulating strings
Manipulating strings
Nicole Ryan
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9
Vince Vo
 
Php String And Regular Expressions
Php String  And Regular ExpressionsPhp String  And Regular Expressions
Php String And Regular Expressions
mussawir20
 
Regular expressionfunction
Regular expressionfunctionRegular expressionfunction
Regular expressionfunction
ADARSH BHATT
 

Ähnlich wie PHP Web Programming (20)

UNIT II (7).pptx
UNIT II (7).pptxUNIT II (7).pptx
UNIT II (7).pptx
 
UNIT II (7).pptx
UNIT II (7).pptxUNIT II (7).pptx
UNIT II (7).pptx
 
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering CollegeString handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
 
Variables In Php 1
Variables In Php 1Variables In Php 1
Variables In Php 1
 
Manipulating strings
Manipulating stringsManipulating strings
Manipulating strings
 
Python regular expressions
Python regular expressionsPython regular expressions
Python regular expressions
 
Adv. python regular expression by Rj
Adv. python regular expression by RjAdv. python regular expression by Rj
Adv. python regular expression by Rj
 
stringsinpython-181122100212.pdf
stringsinpython-181122100212.pdfstringsinpython-181122100212.pdf
stringsinpython-181122100212.pdf
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9
 
php_string.pdf
php_string.pdfphp_string.pdf
php_string.pdf
 
Strings,patterns and regular expressions in perl
Strings,patterns and regular expressions in perlStrings,patterns and regular expressions in perl
Strings,patterns and regular expressions in perl
 
Unit 1-strings,patterns and regular expressions
Unit 1-strings,patterns and regular expressionsUnit 1-strings,patterns and regular expressions
Unit 1-strings,patterns and regular expressions
 
SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)
 
Php String And Regular Expressions
Php String  And Regular ExpressionsPhp String  And Regular Expressions
Php String And Regular Expressions
 
Ch09
Ch09Ch09
Ch09
 
Regular expressionfunction
Regular expressionfunctionRegular expressionfunction
Regular expressionfunction
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and Strings
 
ANSI C REFERENCE CARD
ANSI C REFERENCE CARDANSI C REFERENCE CARD
ANSI C REFERENCE CARD
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
 
Regular expressions in oracle
Regular expressions in oracleRegular expressions in oracle
Regular expressions in oracle
 

Mehr von Muthuselvam RS (7)

UpsilonPiEpsilon-UniversityOfBridgeport-May1997
UpsilonPiEpsilon-UniversityOfBridgeport-May1997UpsilonPiEpsilon-UniversityOfBridgeport-May1997
UpsilonPiEpsilon-UniversityOfBridgeport-May1997
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
 
Gears User Guide
Gears User GuideGears User Guide
Gears User Guide
 
Ant User Guide
Ant User GuideAnt User Guide
Ant User Guide
 
Subversion User Guide
Subversion User GuideSubversion User Guide
Subversion User Guide
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
 
Hibernate Developer Reference
Hibernate Developer ReferenceHibernate Developer Reference
Hibernate Developer Reference
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

PHP Web Programming

  • 1. IntelliBitz Technologies Training Division 168, Medavakkam Main Road Madipakkam, Chennai 91. PH: +91 044 2247 5106 www.intellibitz.com [email_address]
  • 2. PHP WEB PROGRAMMING.
  • 3. CHAPTER 1 STARTING WITH PHP.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. CHAPTER 2 TEXT AND NUMBERS
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58. CHAPTER 3 Making Decisions and Looping
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89. ticks <?php // A function that records the time when it is called function profile($dump = FALSE) {    static $profile;    // Return the times stored in profile, then erase it    if ($dump) {        $temp = $profile;        unset($profile);        return $temp;    } $profile[] = microtime(); } // Set up a tick handler register_tick_function(&quot;profile&quot;); // Initialize the function before the declare block profile(); // Run a block of code, throw a tick every 2nd statement declare(ticks=2) {   for ($x = 1; $x < 50; ++$x) { echo similar_text(md5($x), md5($x*$x)), &quot;<br />;&quot;;    } } // Display the data stored in the profiler print_r(profile(TRUE)); ?>
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96. CHAPTER 4 WORKING WITH ARRAYS
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104. array <?php $array = array(1, 1, 1, 1,  1, 8 => 1,  4 => 1, 19, 3 => 13); print_r($array); ?> Array (    [0] => 1    [1] => 1    [2] => 1    [3] => 13    [4] => 1    [8] => 1    [9] => 19 )
  • 105. array() <?php $firstquarter = array(1 => 'January', 'February', 'March'); print_r($firstquarter); ?> The above example will output: Array ( [1] => January [2] => February [3] => March ) 1-based index with array() <?php $foo = array('bar' => 'baz'); echo &quot;Hello {$foo['bar']}!&quot;; // Hello baz! ?>
  • 106.
  • 107.
  • 108. rsort <?php $fruits = array(&quot;lemon&quot;, &quot;orange&quot;, &quot;banana&quot;, &quot;apple&quot;); rsort($fruits); foreach ($fruits as $key => $val) {    echo &quot;$key = $val&quot;; } ?> The above example will output: 0 = orange 1 = lemon 2 = banana 3 = apple
  • 109.
  • 110. asort <?php $fruits = array(&quot;d&quot; => &quot;lemon&quot;, &quot;a&quot; => &quot;orange&quot;, &quot;b&quot; => &quot;banana&quot;, &quot;c&quot; => &quot;apple&quot;); asort($fruits); foreach ($fruits as $key => $val) {    echo &quot;$key = $val&quot;; } ?> The above example will output: c = apple b = banana d = lemon a = orange The fruits have been sorted in alphabetical order, and the index associated with each element has been maintained.
  • 111.
  • 112. arsort <?php $fruits = array(&quot;d&quot; => &quot;lemon&quot;, &quot;a&quot; => &quot;orange&quot;, &quot;b&quot; => &quot;banana&quot;, &quot;c&quot; => &quot;apple&quot;); arsort($fruits); foreach ($fruits as $key => $val) {    echo &quot;$key = $val&quot;; } ?> The above example will output: a = orange d = lemon b = banana c = apple The fruits have been sorted in reverse alphabetical order, and the index associated with each element has been maintained.
  • 113.
  • 114.
  • 115.
  • 116. natsort <?php $array1 = $array2 = array(&quot;img12.png&quot;, &quot;img10.png&quot;, &quot;img2.png&quot;, &quot;img1.png&quot;); sort($array1); echo &quot;Standard sorting&quot;; print_r($array1); natsort($array2); echo &quot;Natural order sorting&quot;; print_r($array2); ?> The above example will output: Standard sorting Array ( [0] => img1.png [1] => img10.png [2] => img12.png [3] => img2.png ) Natural order sorting Array ( [3] => img1.png [2] => img2.png [1] => img10.png [0] => img12.png )
  • 117.
  • 118. usort <?php function cmp($a, $b) {    if ($a == $b) {        return 0;    }    return ($a < $b) ? -1 : 1; } $a = array(3, 2, 5, 6, 1); usort($a, &quot;cmp&quot;); foreach ($a as $key => $value) {    echo &quot;$key: $value&quot;; } ?> The above example will output: 0: 1 1: 2 2: 3 3: 5 4: 6
  • 119.
  • 120.
  • 121.
  • 122. uksort <?php function cmp($a, $b) {    $a = ereg_replace('^(a|an|the) ', '', $a);    $b = ereg_replace('^(a|an|the) ', '', $b);    return strcasecmp($a, $b); } The above example will output: an apple: 3 a banana: 4 the Earth: 2 John: 1 $a = array(&quot;John&quot; => 1, &quot;the Earth&quot; => 2, &quot;an apple&quot; => 3, &quot;a banana&quot; => 4); uksort($a, &quot;cmp&quot;); foreach ($a as $key => $value) {    echo &quot;$key: $value&quot;; } ?>
  • 123.
  • 124.
  • 125.
  • 126.
  • 127.
  • 128.
  • 129.
  • 130. count <?php $a[0] = 1; $a[1] = 3; $a[2] = 5; $result = count($a); // $result == 3 $b[0]  = 7; $b[5]  = 9; $b[10] = 11; $result = count($b); // $result == 3 $result = count(null); // $result == 0 $result = count(false); // $result == 1 ?> sizeof — Alias of count()
  • 131.
  • 132.
  • 133.
  • 134.
  • 135. each <?php $foo = array(&quot;bob&quot;, &quot;fred&quot;, &quot;jussi&quot;, &quot;jouni&quot;, &quot;egon&quot;, &quot;marliese&quot;); $bar = each($foo); print_r($bar); ?> $bar now contains the following key/value pairs: Array ( [1] => bob [value] => bob [0] => 0 [key] => 0 ) <?php $foo = array(&quot;Robert&quot; => &quot;Bob&quot;, &quot;Seppo&quot; => &quot;Sepi&quot;); $bar = each($foo); print_r($bar); ?> $bar now contains the following key/value pairs: Array ( [1] => Bob [value] => Bob [0] => Robert [key] => Robert )
  • 136.
  • 137.
  • 138. reset <?php $array = array('step one', 'step two', 'step three', 'step four'); // by default, the pointer is on the first element echo current($array) . &quot;<br />&quot;; // &quot;step one&quot; // skip two steps next($array); next($array); echo current($array) . &quot;<br />&quot;; // &quot;step three&quot; // reset pointer, start again on step one reset($array); echo current($array) . &quot;<br />&quot;; // &quot;step one&quot; ?>
  • 139.
  • 140. range // array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'); foreach (range('a', 'i') as $letter) {    echo $letter; } // array('c', 'b', 'a'); foreach (range('c', 'a') as $letter) {    echo $letter; } ?> ?php // array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) foreach (range(0, 12) as $number) {    echo $number; } // The step parameter was introduced in 5.0.0 // array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100) foreach (range(0, 100, 10) as $number) {    echo $number; }
  • 141.
  • 142. in_array <?php $os = array(&quot;Mac&quot;, &quot;NT&quot;, &quot;Irix&quot;, &quot;Linux&quot;); if (in_array(&quot;Irix&quot;, $os)) {    echo &quot;Got Irix&quot;; } if (in_array(&quot;mac&quot;, $os)) {    echo &quot;Got mac&quot;; } ?> The second condition fails because in_array() is case-sensitive, so the program above will display: Got Irix
  • 143.
  • 144.
  • 145.
  • 146.
  • 147.
  • 148.
  • 149.
  • 150.
  • 151.
  • 152.
  • 153.
  • 154.
  • 155. array_walk <?php $fruits = array(&quot;d&quot; => &quot;lemon&quot;, &quot;a&quot; => &quot;orange&quot;, &quot;b&quot; => &quot;banana&quot;, &quot;c&quot; => &quot;apple&quot;); function test_alter(&$item1, $key, $prefix) {    $item1 = &quot;$prefix: $item1&quot;; } function test_print($item2, $key) {    echo &quot;$key. $item2<br />&quot;; } This example will output: Before ...: d. lemon a. orange b. banana c. apple ... and after: d. fruit: lemon a. fruit: orange b. fruit: banana c. fruit: apple echo &quot;Before ...:&quot;; array_walk($fruits, 'test_print'); array_walk($fruits, 'test_alter', 'fruit'); echo &quot;... and after:&quot;; array_walk($fruits, 'test_print'); ?>
  • 156.
  • 157. array_unique <?php $input = array(&quot;a&quot; => &quot;green&quot;, &quot;red&quot;, &quot;b&quot; => &quot;green&quot;, &quot;blue&quot;, &quot;red&quot;); $result = array_unique($input); print_r($result); ?> The above example will output: Array (    [a] => green    [0] => red    [1] => blue ) <?php $input = array(4, &quot;4&quot;, &quot;3&quot;, 4, 3, &quot;3&quot;); $result = array_unique($input); var_dump($result); ?> The above example will output: array(2) {   [0] => int(4)   [2] => string(1) &quot;3&quot; }
  • 158.
  • 159.
  • 160.
  • 161.
  • 162. array_reverse <?php $input  = array(&quot;php&quot;, 4.0, array(&quot;green&quot;, &quot;red&quot;)); $result = array_reverse($input); $result_keyed = array_reverse($input, true); ?> Array (    [2] => Array        (            [0] => green            [1] => red        )    [1] => 4    [0] => php ) Array (    [0] => Array        (            [0] => green            [1] => red        )    [1] => 4    [2] => php ) $result will be $result_keyed will be: This makes both $result and $result_keyed have the same elements, but note the difference between the keys.
  • 163.
  • 164.
  • 165. array_shift <?php $stack = array(&quot;orange&quot;, &quot;banana&quot;, &quot;apple&quot;, &quot;raspberry&quot;); $fruit = array_shift($stack); print_r($stack); ?> This would result in $stack having 3 elements left: Array (    [0] => banana    [1] => apple    [2] => raspberry ) and orange will be assigned to $fruit.
  • 166.
  • 167.
  • 168.
  • 169. array_slice <?php $input = array(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;); $output = array_slice($input, 2);      // returns &quot;c&quot;, &quot;d&quot;, and &quot;e&quot; $output = array_slice($input, -2, 1);  // returns &quot;d&quot; $output = array_slice($input, 0, 3);  // returns &quot;a&quot;, &quot;b&quot;, and &quot;c&quot; // note the differences in the array keys print_r(array_slice($input, 2, -1)); print_r(array_slice($input, 2, -1, true)); Array ( [0] => c [1] => d ) Array ( [2] => c [3] => d )
  • 170.
  • 171.
  • 172.
  • 173.
  • 174.
  • 175. array_key <?php $array = array(0 => 100, &quot;color&quot; => &quot;red&quot;); print_r(array_keys($array)); $array = array(&quot;blue&quot;, &quot;red&quot;, &quot;green&quot;, &quot;blue&quot;, &quot;blue&quot;); print_r(array_keys($array, &quot;blue&quot;)); $array = array(&quot;color&quot; => array(&quot;blue&quot;, &quot;red&quot;, &quot;green&quot;),                &quot;size&quot;  => array(&quot;small&quot;, &quot;medium&quot;, &quot;large&quot;)); print_r(array_keys($array)); ?> The above example will output: Array ( [0] => 0 [1] => color ) Array ( [0] => 0 [1] => 3 [2] => 4 ) Array ( [0] => color [1] => size )
  • 176.
  • 177.
  • 178.
  • 179.
  • 180.
  • 181.
  • 182.
  • 183.
  • 184.
  • 185.
  • 186.
  • 187. array_intersect_ukey <?php function key_compare_func($key1, $key2) {    if ($key1 == $key2)        return 0;    else if ($key1 > $key2)        return 1;    else        return -1; } The above example will output: array(2) { [&quot;blue&quot;]=> int(1) [&quot;green&quot;]=> int(3) } $array1 = array('blue'  => 1, 'red'  => 2, 'gree