Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thanks all and special thank to Stanislav Shabalin who really help me.</p> <p>I write my function which run successfully :) bellow :</p> <pre> /** * Get a distinct multi dimensional array * * @param array $array * array to distinct * @param string $keySearch * string key to search double array * @param boolean $overwrite = false * boolean to allow values to be overwritten * @param array $exception = array() * array of keys to not overwrite if overwrite is true * * @return array $result * Return a multi dimensional array witch has been distinct. */ public static function distinctMultiDimensionalArray($array, $keySearch, $overwrite = false, $exception = array()) { // Check if it's an array if( !is_array($array) ) return false; $result = array(); foreach ( $array as $entry ) { // If email doesn't exist if ( !isset($result[$entry[$keySearch]]) ) $result[$entry[$keySearch]] = $entry; else { // If email exist foreach ( $entry as $key => $value ) { if( !empty($value) ) { // If not empty value and this value is different from before and you don't want to overwrite values // Or you want to overwrite values except some keys if( ( !empty( $result[$entry[$keySearch]][$key] ) && $result[$entry[$keySearch]][$key] != $value && $overwrite == false ) || ( $overwrite == true && in_array($key, $exception) ) ) $result[$entry[$keySearch]][$key] = $result[$entry[$keySearch]][$key] . ', ' . $value; else $result[$entry[$keySearch]][$key] = $value; } } } } $result = array_values($result); return $result; } </pre> <p>Thanks a lot !</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload