|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
I have one variable name $mobile.
The $mobile hold the value of mobile number which is 10 digit only. Let say : $mobile = '0192995682'; So how do I split this value '0192995682' and seperate that number and store it to two new variable. $first = '019'; $last = '2995682'; The $first variable hold the first 3 digit of the $mobile value and $last hold the value digits left. I want the $mobile value in split because i have to know the first 3 digit.Beacuse in my page i gonna do some checking regard of this digit. Anyone,help me please! |
|
#2
|
|||
|
|||
|
In php you have access to any string as an array of characters. So you could easily create first as follows -
$first = $mobile[0] . $mobile[1] . $mobile[2]; Failing that (and for any more advanced functionality you might need) look up the str* functions at www.php.net which do all kinds of string splicing. -KM- |
|
#3
|
|||
|
|||
|
Now I know. Thank u kode monkey. But i figure it out using substr() function.
$first = substr($mobile,0,3); Then i got the digits that i want. But many thanks for your information. |
|
#4
|
|||
|
|||
|
Yeah thats a much nicer way to do it, my way is definitely a bit of a hack.
-KM- |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > How to split the value of this variable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|