hi all,
i need to split a string and place it in two strings..like
$f1=123 4567 is a string.
i need to place 123 in $f2 and 4567 in $f3
how to do that can any one help me
hi all,
i need to split a string and place it in two strings..like
$f1=123 4567 is a string.
i need to place 123 in $f2 and 4567 in $f3
how to do that can any one help me
Here is ur code.
<?
$f1='123 4567';
$temp = explode(' ',trim($f1));
$f2 = $temp[0];
$f3 = $temp[1];
?>
Hi Dear,
<?php
$string = "123 4567";
$result = explode(" ", $string);
echo $var_1=$result[0];
echo $var_2=$result[1];
?>
Yes, the same code as i write.
Hi Dear,
<?php
$string = "123 4567";
$result = explode(" ", $string);
echo $var_1=$result[0];
echo $var_2=$result[1];
?>
I think what you are after is the str_split(), unset(), and implode() functions. Below is an example of how I would do it.
<?php
function parts($string) {
$tmp=str_split($string,3);
$a=$tmp[0];
unset($tmp[0]);
$b=implode('',$tmp);
return array($a,$b);
}
///////////////////////////////////////
//Do Not Edit Above
$data = parts(1234567890);
echo $data[0];
echo '<br>';
echo $data[1];
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.