How to extract a substring from a string in PHP until it reaches a certain character?

前端 未结 5 2129
野趣味
野趣味 2020-12-11 18:37

I have part of a PHP application which assess a long string input by the user, and extracts a number which always begins 20 characters into the string the user supplies.

5条回答
  •  心在旅途
    2020-12-11 18:54

    Going to just add on to Gumbo's answer in case you need help with the substring function:

    $pos = strpos($str, '"', 20);
    $substring = substr($str, 20, $pos);
    

提交回复
热议问题