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? 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] 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 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 Link to comment https://forums.phpfreaks.com/topic/148387-solved-cutting-string/#findComment-779081 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.