• 0

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /var/www/html/cnasolution/site/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/site/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/site/index.php
Line: 315
Function: require_once

I'd like to get the index of each overlapping occurrence in a given string.

For example:

var source = 'NNNHRMSLGGGGEAZZ' var toFind = ['HRMSL', 'NN', 'ZZ', 'GGG'] find(source, toFind) // should print line by line:  'NN' found at index 0                                                     'NN' found at index 1                                                     'HRMSL' found at index 2                                                     'GGG' found at index 8                                                     'GGG' found at index 9                                                     'ZZ' found at index 13 

How can I achieve this without using for or while loops (forEach is fine)?

I tried doing it multiple ways but all of them don't take into account overlapping items, which is quite tricky to do.

Thank you for your help.

Download script demo [LINK] [Origin]
Download script demo [LINK 2] [Onedrive] Download script demo [LINK 2] [Google drive]