For this, use preg_match_all(). Let’s say the following is our string
$values = 'javamysqlphpmongodbpythonspringhibernatephp';
We want to split with specific values like
java hibernate php
Example
The PHP code is as follows
<!DOCTYPE html> <html> <body> <?php $values = 'javamysqlphpmongodbpythonspringhibernatephp'; $afterSpliting = preg_match_all("/(java|hibernate|php)/", $values, $result); print_r($result); ?> </body> </html>
Output
This will produce the following output
Array ( [0] => Array ( [0] => java [1] => php [2] => hibernate [3] => php ) [1] => Array ( [0] => java [1] => php [2] => hibernate [3] => php ) )