Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function compareArray($parameter){
- $products = array(
- 'paper' => array(
- 'copier' => "A",
- 'inkjet' => "Inkjet Printer",
- 'laser' => "Laser Printer",
- 'photo' => "Photographic Paper"),
- 'pens' => array(
- 'copier' => "B",
- 'inkjet' => "Highlighters",
- 'marker' => "Markers"),
- 'misc' => array(
- 'copier' => "C",
- 'inkjet' => "Adhesives",
- 'clips' => "Paperclips")
- );
- $a = array();
- echo "<pre>";
- foreach($products as $section => $items)
- array_push($a,$items[$parameter]);
- print_r($a);
- $b = $a;
- sort($b);
- print_r($b);
- if ($a == $b){
- print_r("Arrays are the same");
- return true;}
- else{
- print_r("Arrays are different");
- return false;
- }
- echo "</pre>";
- }
- compareArray(copier);
- compareArray(inkjet);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement