1

e.g. Input Array

array ([0] => Array
    (
        [date] => 2016-11-16
        [cook_book_id] => 89
        [occassion] => Not set
    )

[1] => Array
    (
        [date] => 2016-11-16
        [cook_book_id] => 90
        [occassion] => Diwali
    )

[2] => Array
    (
        [date] => 2016-11-16
        [cook_book_id] => 95
        [occassion] => Not set
    )
[3]  => Array
    (
        [date] => 2016-11-17    
        [cook_book_id] => 95
        [occassion] => Not set
    )
)

Output should Be

  array([0] => Array
    (
        [date] => 2016-11-16
        [cook_book_id] => 89
        [occassion] => Diwali
    )
    [1]  => Array
    (
        [date] => 2016-11-17
        [cook_book_id] => 95
        [occassion] => Not set
    )
)

In input array "date" and "Not Set" value is repeated from input array i want unique date value with occassion name "diwali"(high priority) which can be any value if not then default value should be "Not Set" i.e. if Not Set should get override with "diwali" else it should be "Not Set"

1 Answers1

0

Possibly this, if I understand you correctly.

<?php
$today = date('Y-m-d');

foreach($array as $key => $value){
    if($value['occassion'] === 'Not Set' && $value['date'] === $today){
        $array[$key]['occassion'] = 'Birthday';
    }
}
Antony Thompson
  • 1,608
  • 1
  • 13
  • 22
  • Is it what you need? – Antony Thompson Nov 24 '16 at 10:38
  • It is not just only birthday value it can be any value such as "diwali" or "holi" anyvalue which is unknown ,the known value Is only "Not Set" where we can use to check the value of occasion. and date is also unknown which can be any date not particular date so only we can take out unique date value where it has occasion "Not Set" or "any occasion name" but if repeated date has some occasion name "diwali" or "dassera" or "any occasion name" it should override "Not Set" Value in occasion – Navjyot Gaonkar Nov 24 '16 at 10:44
  • I think that is what you want? It would help maybe if you show the code you have tried already. I'm having trouble understanding your explanation properly. – Antony Thompson Nov 24 '16 at 10:46
  • i have update my question see if you understand my question through code if not i will provide you code – Navjyot Gaonkar Nov 24 '16 at 11:12