PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
Hi,
I'm trying to create an array with the following structure
//Fields to search
$fields = array("title", "excerpt", "body", "fname", "lname");
//Word to search
$word = "hello";
$conditions = array("active"=>1);
//**** THIS IS WHAT I WANT TO CREATE VIA A LOOP ***
$conditions["or"] = array($fields[0]=>"LIKE %".$word."%");
$conditions["or"]["or"] = array($fields[1]=>"LIKE %".$word."%");
$conditions["or"]["or"]["or"] = array($fields[2]=>"LIKE %".$word."%");
$conditions["or"]["or"]["or"]["or"] = array($fields[3]=>"LIKE %".$word."%");
$conditions["or"]["or"]["or"]["or"]["or"] = array($fields[4]=>"LIKE %".$word."%");
I'm sure recursion is the way to go but how to loop for the number of keys per index?
Any help would be highly appreciated.
Kind Regards,
Navneet
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.