Show specific values of languagetool API on specific word on Textarea

lalarukh

Lalarukh khan

Posted on May 25, 2022

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

💖 💪 🙅 🚩
lalarukh
Lalarukh khan

Posted on May 25, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related