I am attempting to create an implode that given the following array:
<?php
$conditions = array(
'username' => array('=', 'nblackburn'),
'password' => array('=', 'password')
);
$output = array();
foreach($conditions as $key => $values) {
$output[] = $key.' '.implode(' ', $values);
}
echo implode(' AND ', $output);
?>
Should return a string like the following:
username = nblackburn AND password = password
However, I am having problems getting it to work. As you can see the first section (username) is the array’s key, the second (=) is the first element in the sub-array and the final (nblackburn) is its last element.
Like this?
But as mentioned in the comments, don’t use it, if it brings vulnerabilities with it!