How can I delete an array index by comparing it to another array index?
PHP:
$results = array ( array(
"Name" => $NameUser,
"Surname" => $SurnameUser,
"MyComment" => $MyComment,
"VideoPath" => $VideoPath,
"Reg_Date" => $Reg_Date,
"ThumbPath" => $ThumbPath,
"UserId" => $UserId
));
print_r($results[0]); // Array ( [Name] => aaa [Surname] => aaa [MyComment] => aaa [VideoPath] => aaa [Reg_Date] => aaa [ThumbPath] => aaa [UserId] => aaa)
$JSON_List = file_get_contents('test.json');
$arr = json_decode($JSON_List);
print_r($arr[0]); // stdClass Object ( [Name] => aaa [Surname] => aaa [MyComment] => aaa [VideoPath] => aaa [Reg_Date] => aaa [ThumbPath] => aaa [UserId] => aaa )
I can see these two indexes are identical, I am using a for loop but it seeks that php are not seeing them as identical.
How can I compare the array properly and if identical remove the identical array index from the list?
PHP:
foreach ($arr as $index) {
$countIndex++;
print_r($countIndex);
if ($arr[$countIndex - 1] == $results[0]) {
print_r("array is identical \n");
}else{
print_r("array is not identical \n");
}
}
0 comments:
Post a Comment