开发者

Getting values with preg_match_all

开发者 https://www.devze.com 2023-02-12 05:25 出处:网络
How can I get each value returned by PHP preg_match_all using for each loop, because I want to insert each value in database.开发者_开发百科

How can I get each value returned by PHP preg_match_all using for each loop, because I want to insert each value in database.开发者_开发百科 Thanks


preg_match_all('/pattern/', $haystack, $matches);
foreach($matches[0] as $match) {
    echo $match;
}

The third parameter is the variable where the matches will be stored. You can use print_r($matches) to see the structure of the array and design your code accordingly

0

精彩评论

暂无评论...
验证码 换一张
取 消