summaryrefslogtreecommitdiffstats
path: root/library/Pbs/Search.php
diff options
context:
space:
mode:
authorSimon2011-04-04 15:34:22 +0200
committerSimon2011-04-04 15:34:22 +0200
commitd3accaaab0cfb3d3178d349c12baf821dcf38899 (patch)
treec4b29a7e0811cacbca1e91c35b981115ae8e17ed /library/Pbs/Search.php
parentPagination in den Controllern Korrigiert (diff)
downloadpbs2-d3accaaab0cfb3d3178d349c12baf821dcf38899.tar.gz
pbs2-d3accaaab0cfb3d3178d349c12baf821dcf38899.tar.xz
pbs2-d3accaaab0cfb3d3178d349c12baf821dcf38899.zip
Suche in Clients eingebettet
Diffstat (limited to 'library/Pbs/Search.php')
-rw-r--r--library/Pbs/Search.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/library/Pbs/Search.php b/library/Pbs/Search.php
new file mode 100644
index 0000000..279cba6
--- /dev/null
+++ b/library/Pbs/Search.php
@@ -0,0 +1,51 @@
+<?php
+
+class Pbs_Search{
+ public function search($array, $search){
+ $parts = explode(" ",$search);
+ foreach($parts as $search){
+ if(stristr($search,":") && ctype_alpha(substr($search,0,strpos($search,":")))){
+ $key = substr($search,0,strpos($search,":"));
+ $value = substr($search,strpos($search,":")+1);
+ $searcha[$key] = $value;
+ }
+ else{
+ $searchb[] = $search;
+ }
+ }
+ foreach($array as $counter => $cig){
+ foreach($cig as $k => $v){
+ if(count($searcha) > 0){
+ foreach($searcha as $sk => $sv){
+ if($k == $sk){
+ if(stristr($v,$sv)){
+ $com1[] = $counter;
+ }
+ }
+ }
+ }
+ if(count($searchb) >= 0){
+ foreach($searchb as $sk => $sv){
+ $comm = stristr($v,$sv);
+ if($comm != false){
+ $com2[] = $counter;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (count($searcha) == 0){
+ $data = $com2;
+ }
+ if (count($searchb) == 0){
+ $data = $com1;
+ }
+ if (count($searcha) > 0 && count($searchb) > 0){
+ $data = array_intersect($com1,$com2);
+ }
+ foreach( $data as $c)
+ $ges[] = $array[$c];
+ return $ges;
+ }
+}