Get line number from preg_match_all()

前端 未结 10 1091
天命终不由人
天命终不由人 2021-02-07 09:23

I\'m using PHP\'s preg_match_all() to search a string imported using file_get_contents(). The regex returns matches but I would like to know at which line number those matches a

10条回答
  •  长发绾君心
    2021-02-07 09:52

    i think first of all, you need to read the $String into an array, each element stand for each line, and do look like this :

    $List=file($String);
    for($i=0;$i

提交回复
热议问题