from a sequence of numbers I want to extract 10 digits that begins by 514
Example 2134565323551412344558987
With preg_match or any other php code I want to extract the 5141234455
I Tried this code
preg_match_all("/^514/", $contentNumbersFromURL, $matches)
Bu I get
array(1) { [0] => array(0) {} }
You need to remove start of the line anchor ^
. ^
matches the line starting boundary. Since there isn't a number 514
exists at the start, your regex got failed.
preg_match_all('/514\d{7}/', $contentNumbersFromURL, $matches)