PHP Classes
elePHPant
Icontem

File: array-search-example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of ALPESHKUMAR B PANCHAL  >  PHP Array Search  >  array-search-example.php  >  Download  
File: array-search-example.php
Role: Example script
Content type: text/plain
Description: Example file
Class: PHP Array Search
Search for patterns in arrays using wildcards
Author: By
Last change: replaced underscore with hyphens into filename
Date: 2 years ago
Size: 2,069 bytes
 

Contents

Class file image Download
<?php
   
require_once "array-search-class.php";

$array = array(
    
'testing' => 'hi how are you',
    
'software' => array(
           
'vb.net' => array('asp.net', 'c#'),
           
'php' => array('object oriented','script'),
            ),
    
'php frameworks' => array('wordpress','joomla','magento','zend framework','yii'),
    
'wordpress' => array('plugin','widget','template'),
    
'joomla' => array('plugin','widget','template'),
    
'zend framework' => array('template','plugin'),
    
'magento' => array('skin','template'),
    
'extra1' => array('one1','extra6'),
    
'extra2' => array('one2','two'=>array('three'=>array('extra6'))),
    
'extra3' => 'one3',
    
'extra4' => 'One4',
    
'extra5' => 'one5',
    
'extra6' => 'one6',
    
'king' => array('kingdom','queen','troop','states','soldier'),
    
'extra7' => array('one1'),
);

$array_search = new array_search();

echo
"<pre>";


echo
'1. search array from array values only with a word ending with "framework"
'
;
$result = $array_search -> array_like($array, '%framework', 'value', false );
print_r($result);


echo
'2. search array from array values only with a word begining with "one"
'
;
$result = $array_search -> array_like($array, 'one%', 'value', false );
print_r($result);


echo
'3. search array from array values only with a word "One" [case sensitive]
'
;
$result = $array_search -> array_like($array, '%One%', 'value', true );
print_r($result);


echo
'4. search array from array keys only with a word begining with "php"
'
;
$result = $array_search -> array_like($array, 'php%', 'key', false );
print_r($result);


echo
'5. search array from array keys and values with a word "one" which can be anywhere in a keys or values
'
;
$result = $array_search -> array_like($array, '%one%', 'both', false );
print_r($result);


echo
'6. search array from array keys and values with a word "one" which can be anywhere in a keys or values
'
;
$result = $array_search -> array_like($array, '%one%', 'both', false );
print_r($result);
echo
"</pre>";
?>