-2

I have the following url : http://example.com/category/post-is-783476?src=mainPage. With the pattern How to get the numbers(78346) from the url ?

Touheed Khan
  • 2,149
  • 16
  • 26
Jahid
  • 77
  • 1
  • 9

1 Answers1

0

Something like

<?php
$input_line = "http://example.com/category/post-is-783476?src=mainPage";
preg_match("/([0-9]+)\/?/", $input_line, $output_array);
echo $output_array[1];
?>

Output: 783476

Pieter De Clercq
  • 1,951
  • 1
  • 17
  • 29