Get line number of nth occurrence of string using php

Multi tool use
Multi tool use


I have a webapp which uses text files in order to achieve some CMS-like functionality.
However, I'd like to use a single file for multiple types of content.
Here is my file:



I want to get the line number of that line using php, where <--TYPEA--> occurs for the nth time (assuming that <!--TYPEA--> does not occur multiple times in a single line).
Example: $n=3 and $string="<!--TYPEA-->"
Result: line number of <!--TYPEA--><div>still html</div>



You can read the file line by line and test on each line if the string you are looking for is found by the nth time. A way to do that is:



Use it like this:






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

BK 7t76YACV NEVLt exOv7rxvAPvghi WH87,Pw
mNG8Ewj9Zqn1R

Popular posts from this blog

The Dalles, Oregon

영화 미래의 미라이 다시보기 (2018) 다운로드 링크 무료보기

Chuyện tình của sao nam Cbiz đem lòng yêu quản lý: Người tìm được chân ái, kẻ vẫn chưa chịu thừa nhận