I am trying to access certain subarrays of an array depending on a sha1 code saved in the subarray. I have the following code working for me:
//I take a sha1 string of 40chars from GET
if(isset($_REQUEST['sha1'])){
//then I iterate through the array and check if the subarrays sha1 matches
for($i = 0; $i < count($scomplaints); $i++) {
if($scomplaints[$i]['sha1'] == $_REQUEST['sha1']){
//once a match is found I delete the match...
unset($scomplaints[$i]);
//... reserialize the array and update it in the database
$new_c = serialize($scomplaints);
// ( add new array to database )
break;
}
}
}
Pretty straight forward. Only problem is: In some random cases the loop doesnt read the sha1 value of the subarray. Instead it reads an empty string from the array.
But when i var_dump the array the sha1 code is clearly saved in the array and also identical to the one I get from GET (I did a by hand comparison).
I can't figure out what the problem is, maybe some encoding error? Maybe one of you guys can help me with this?
Thanks for all advice.
GET
value).