I know how to perform an SQL LIKE % query for a single value like so:
SELECT * FROM users WHERE name LIKE %tom%;
but how do I do this if th
Blockquote
/** * Implode a multidimensional array of values, grouping characters when different with "[]" block. * @param array $array The array to implode * @return string The imploded array */ function hoArray2SqlLike( $array ) { if ( ! is_array( $array ) ) return $array;
$values = array();
$strings = array();
foreach ( $array as $value )
{
foreach ( str_split( $value ) as $key => $char )
{
if ( ! is_array( $values[ $key ] ) )
{
if ( isset( $values[ $key ] ) )
{
if ( $values[ $key ] != $char )
{
$values[ $key ] = array( $values[ $key ] );
$values[ $key ][] = $char;
}
}
else
$values[ $key ] = $char;
}
elseif ( ! array_search( $char , $values[ $key ] ) )
$values[ $key ][] = $char;
}
}
foreach ( $values as $value )
{
if ( is_array( $value ) )
$value = '['.implode( '', $value ).']';
$strings[] = $value;
}
return implode( '', $strings );
}