Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Extract numbers after the last hyphen in PHP?
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
<!DOCTYPE html>
<html>
<body>
<?php
$values = "John-45-98-78-7898906756";
$values = explode("-",$values);
$values = $values[4];
echo $values;
?>
</body>
</html>
Output
7898906756
Advertisements
