Use preg_split() in PHP and split with hyphen. Let’s say the following is our input value with numbers and string separated with hyphen
$values ="ABC-DEF IJKL-3553435-8990987876";
We want the output to be
Array ( [0] => ABC-DEF IJKL [1] => 3553435 [2] => 8990987876 )
Example
The PHP code is as follows
<!DOCTYPE html> <html> <body> <?php $values ="ABC-DEF IJKL-3553435-8990987876"; $exploded = preg_split('/-(?=[0-9])/', $values, 3); print_r($exploded); ?> </body> </html>
Output
This will produce the following output
Array ( [0] => ABC-DEF IJKL [1] => 3553435 [2] => 8990987876 )