# Extract numbers after the last hyphen in PHP?

PHPServer Side ProgrammingProgramming

Let’s say the following is our string including hyphen and numbers as well −

"John-45-98-78-7898906756"

To extract numbers after – i.e. hyphen, use the concept of explode() with parameters - and $yourVariableName. The PHP code is as follows − ## Example Live Demo <!DOCTYPE html> <html> <body> <?php$values = "John-45-98-78-7898906756";
$values = explode("-",$values);
$values =$values[4];
echo \$values;
?>
</body>
</html>

## Output

7898906756
Published on 20-Nov-2020 05:36:14