Show languagetool values according to position of texrarea text

Hi,
I’m using Languagetool API and trying to make a grammar & spellchecker by using PHP. I can highlight or color the first letter of wrong word. The problem is that I’m getting all suggestion values from API json array once. I want to show specific array replacement based on ‘offset’ parameter below specific word. Not al together.
API has replacement values according to offset parameter e.g. 0, 3, 6

By this loop I’m calling all values from inside matches → replacements → values.

foreach ($json2['matches'] as $key=>$val) {       //getting inside matches all arrays
      foreach ($val['replacements'] as $new=>$qwe) {     //all replacement arrays
            echo '<input type="button" value="'.$qwe['value'].'">';    //all values
      }
}

This is how Its showing on my context-menu.


I want to get the wrong from textarea by its index position and show appropriately only its specific replacement array.
Seeking Guidance.

:flushed:you are such a genius mam, it’s too hard for me, I can’t do it…

I understand, Thank you!