EchoFool Posted March 7, 2009 Share Posted March 7, 2009 I need help, I tried to cut a string to get the integer but it fails every time.... it returns "Array". This is what im trying: $i = 'userid=2'; $vars = split("=", $i); Echo $vars; Just want it to echo '2'. Where am i going wrong? Quote Link to comment https://forums.phpfreaks.com/topic/148387-solved-cutting-string/ Share on other sites More sharing options...
wildteen88 Posted March 7, 2009 Share Posted March 7, 2009 split will return an array To retrieve 2 you'll need to use $vars[1] Quote Link to comment https://forums.phpfreaks.com/topic/148387-solved-cutting-string/#findComment-779068 Share on other sites More sharing options...
daanoz Posted March 7, 2009 Share Posted March 7, 2009 it is doing exactly what you ask... the split function returns an array with 2 elements: [0] = userid [1] = 2 so to return the second part: $i = 'userid=2'; $vars = split("=", $i); echo $vars[1]; Cheers Quote Link to comment https://forums.phpfreaks.com/topic/148387-solved-cutting-string/#findComment-779071 Share on other sites More sharing options...
EchoFool Posted March 7, 2009 Author Share Posted March 7, 2009 Ohhh right thanks guys ! i understand now Quote Link to comment https://forums.phpfreaks.com/topic/148387-solved-cutting-string/#findComment-779081 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.