Jump to content

[SOLVED] Super quick question


tmh766

Recommended Posts

So there is no simple predefined way to do it, I have to use this

 

function Array_Search_Preg( $find, $in_array, $keys_found=Array() )
{
   if( is_array( $in_array ) )
   {
       foreach( $in_array as $key=> $val )
       {
           if( is_array( $val ) ) $this->Array_Search_Preg( $find, $val, $keys_found );
           else
           {
               if( preg_match( '/'. $find .'/', $val ) ) $keys_found[] = $key;
           }
       }
       return $keys_found;
   }
   return false;
} 

It's pretty simple...

 

<?php
//returns an array with the keys that their values have the search string in them (can be an empty array)

function sub_search($array, $search)
{
$results = array();
foreach($array as $key => $val)
{
	if(strpos($val,$search) !== FALSE)
		$results[] = $key;
}
return $results;
}

?>

 

Orio.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.