UPDATE
I found an answer to this question for myself and I posted it, but i can only accept it in two days..
I create this multidimensional array:
array (
0 =>
array (
'OrderDate' => '02.11.2018',
'ClientNumber' => 5500
)
)
array (
0 =>
array (
'OrderDate' => '02.11.2018',
'ClientNumber' => 5500
)
)
array (
0 =>
array (
'OrderDate' => '05.03.2018',
'ClientNumber' => 5500
)
)
array (
0 =>
array (
'OrderDate' => '10.12.2018',
'ClientNumber' => 2200
)
)
array (
0 =>
array (
'OrderDate' => '10.12.2018',
'ClientNumber' => 2200
)
)
The array shouldn't contain duplicate OrderDate's from each ClientNumber.
I want the output to look like this:
array (
0 =>
array (
'OrderDate' => '02.11.2018',
'ClientNumber' => 5500
)
)
array (
0 =>
array (
'OrderDate' => '05.03.2018',
'ClientNumber' => 5500
)
)
array (
0 =>
array (
'OrderDate' => '10.12.2018',
'ClientNumber' => 2200
)
)
What if-condition should i use to make my output look like this? Any help will be appreciated, thank you!
This is my function that is called in a foreach. I tried my best to check with in_array and array_column but the output didn't look like the code above.
$array = array();
function createArray($clientNr, $orderDate){
if(empty($array)){ // if array is empty, just add
$array[] = array(
"OrderDate"=>$orderDate,
"ClientNumber"=>$clientNr
);
} else {
if(??????)<--------------------------- // check here if date from clientnumber exists
$array[] = array(
"OrderDate"=>$orderDate,
"ClientNumber"=>$clientNr
);
}
}
}