Hey , Lets say I have userid=123-456-765 How can I put in variable only the " 123 " it can be also 12345 , I mean how can I take all numbers from start until the first "-" and put them in a variable. Thank you in advance for your help !
Play with this: $userid = '123-456-765'; $parts = explode('-', $userid); print_r($parts) Code (markup):
Simplest way: $userid = '123-456-765'; $num = explode('-', $userid); $newid = $num[0]; echo $newid; Code (markup):