PHP script won't delete Json object

Hello,

I’m trying to make a form where the user has to put in a name, after submitting the Json object that contains that name should be deleted. I’ve tried something but that doesn’t work even though I think I’m not far off. This is my code:

Json:

[ 

{ 

"naam":"Jef Reynders",
"functie":"Jeugdbestuur",
"telnummer":"0477 30 01 79",
"foto":"..\/img\/bestuursleden\/jefreynders.jpg"

},
{ 

"naam":"Bert Belmans",
"functie":"Jeugdbestuur",
"telnummer":"0476 71 80 76",
"foto":"..\/img\/bestuursleden\/bertbelmans.jpg"

},
{ 

"naam":"Tom Dens",
"functie":"Jeugdbestuur",
"telnummer":"0499 10 42 75",
"foto":"..\/img\/bestuursleden\/tomdens.jpg"

}

]

my script:

<?php  
 $message = '';  
 $error = '';  
 if(isset($_POST["submit"]))  
 {  
      $teller=0;
      while($teller!=1){

        if(file_exists('../json/jeugdwerking.json'))  
           {  
                $current_data = file_get_contents('../json/jeugdwerking.json');  
                $array_data = json_decode($current_data, true);  
                
                foreach ($array_data as $key => $value) {
    
                    if ($key->naam == $_POST["naam"]) {
                        unset($array_data[$key]);
                    }
    
                }

                file_put_contents($current_data, json_encode($array_data));
                
           }  
            


           $teller++;
        }
      
           
       
 }  
 ?>

so what I’m trying to do is to decode the Json and make an array, then I loop through that array to see if there is anything that matches the name (textbox of the form is called “naam”). Sadly nothing happens when I try to run it.

What does the html page look like for the form that calls the php script (shown above)?