output value of json array and then sent another get request

i am really new to stackoverflow and actually dont have any clue about php.

I have a json array which looks like

[{"betreff":"h"},{"betreff":"VS Code fehlt"}]

i´ve created (copied :D) a foreach loop
to output the “h” and “VS Code fehlt”

function display_array_recursive($json_rec){

if($json_rec){
    foreach($json_rec as $key=> $value){
        if(is_array($value)){
            display_array_recursive($value);
        }else{
            echo '<a href="#"  onClick="test("'.$value.'")">';
        }
    }
}

As we can see now the “h” and “VS Code fehlt” parts are being outputted as links. I want to make it so that whenever I click on the link a new get requests should be sent out with the giving value.

function test($value){when pressed = send new file_get_contents request to localhost/api/ticket/{$value}}

i hope i could describe good enough what i want.
Thanks in advance, please inform me if anything is unclear