Saravanan M P Saravanan M P - 1 year ago 68
PHP Question

How to separate a string and store in two variables in PHP

I have string

, and I want store this string in two variables. One is
and the other
How should I use a string function to get it like this?

Answer Source

You can also use preg_split():

$matches = preg_split('/\./', $ab);
$a = isset($matches[0]) ? $matches[0] : '';
$b = isset($matches[1]) ? '.' . $matches[1] : '';
// Print if you want by uncommenting the next line
// print $a . ' ' . $b;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download