PHP Finding Nth Occurrence Of Match – String Function

<?php
preg_match("/\d/", "1 and 2 and 3 and 4", $matches);
echo "Value: " . $matches[0][2] . "\n"; ?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.