DEV Community

Lalarukh khan
Lalarukh khan

Posted on

Show specific values of languagetool API on specific word on Textarea

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
      }
}
Enter fullscreen mode Exit fullscreen mode

This is how Its showing on my context-menu.
Image description
I want to get the wrong word from textarea by its index position and show appropriately only its specific replacement array.
Seeking Guidance.
My JSON File:

Image description

Top comments (0)