mysql - php | Convert array to FIND_IN_SET -


i'm trying convert array query string. may can me.

my array looks like:

array (     [3] => array         (             [0] => 7             [1] => 13             [2] => 1         )      [4] => array         (             [0] => 14             [1] => 2         )  ) 

and i'm trying convert into:

(find_in_set('13', vals) || find_in_set('7', vals) || find_in_set('1', vals)) , (find_in_set('14', vals) || find_in_set('2', vals)) 

how can this? thanks!

this may you.

 [akshay@localhost tmp]$ cat test.php  <?php   $array = array(array(7,13,1),array(14,2));   function convert_to_string($array)  {   return implode(" , ",array_map(function($v){ return "(".implode(" || ", array_map( function($q){ return sprintf("find_in_set('%s', vals)",$q);},array_values($v))).")";},array_values($array)));      }   echo convert_to_string($array);   ?> 

output

 [akshay@localhost tmp]$ php test.php  (find_in_set('7', vals) || find_in_set('13', vals) || find_in_set('1', vals)) , (find_in_set('14', vals) || find_in_set('2', vals)) 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -