underline the nth word of a string based on an array in php/laravel


I have passed some paginated data to my blade view like this:

     @foreach ($result as $item)
        {{ $item->text}} :
     {{ $result->links() }}

//outputs 3 strings

I have an array with 3 elements that contains the respective locations of each word in each string that should be "underlined":

array:3 [▼
  0 => 19
  1 => 5
  2 => 3

So 19 means, the 19th word of the first string that will be underlined. Likewise 5 and 3 mean the 5th and the 3rd words in the second and the third string.

So, what should I write in my loop to underline nth word in a string based on a given array?

Can you please give me a tip?

Source: Laravel

Categorised as laravel, php, replace, string Tagged , , ,


Leave a Reply

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us