consider bellow variable x.is there any method to separate this to two parts at the "slash" and assign them to two variable in php. there should be only the slash between two words.
<?php
$x="hello/welcome";
?>
consider bellow variable x.is there any method to separate this to two parts at the "slash" and assign them to two variable in php. there should be only the slash between two words.
<?php
$x="hello/welcome";
?>
<?php
$x="hello/welcome";
$a = explode("/", $x);
// $a[0] = "hello"
// $a[1] = "welcome"
?>
Is that helpful?
You can use explode and preg_split both .Try this:-
<?php
$x="hello/welcome";
$array = explode("/", $x);
echo "<pre/>";print_r($array);
?>
Or
<?php
$x="hello/welcome";
$y = preg_split('^/^',$x);
print_r($y);
?>
In both condition output is:-
Array
(
[0] => hello
[1] => welcome
)