0

I have array in PHP:

array(3) {
  [0]=>
  array(2) {
    ["Faktas"]=>
    string(1) "A"
    ["value"]=>
    string(4) "true"
  }
  [1]=>
  array(2) {
    ["Faktas"]=>
    string(1) "B"
    ["value"]=>
    string(4) "true"
  }
  [2]=>
  array(2) {
    ["Faktas"]=>
    string(1) "A"
    ["value"]=>
    string(5) "false"
  }
}

I want to compare values inside array and remove them from array if ($d["Faktas"] == d["Faktas"])&&($d["value"]!=$d["value"]) I would like to remove them both from my $data array. I am using foreach loop:

foreach ($data as $d) {
   // if($d["Faktas"]==){}
}

Don't know how to set my indexes.

Aipo
  • 1,805
  • 3
  • 23
  • 48
  • foreach ($array as $key => $value) { unset( $array[$key] ); } – Pete May 16 '17 at 15:51
  • I want to remove if ["Faktas"] values are same, but ["value"] are not same. Can you show it how it works with data, or example. What values `$key`get in you example? – Aipo May 16 '17 at 15:59
  • You might rethink your data holding then. Use switch variables instead. $faktas = 'A'; if ($nextFakta != $faktas){ ... } – Pete May 16 '17 at 16:03

0 Answers0