thernes Posted January 30, 2010 Share Posted January 30, 2010 Hi guys Total noob here, so bear with me... I am trying to build a script for something and I need to get the username and password from an api. I have managed to get the script to send the correct command and the api will then reply with: username,password. How would I proceed to get these values as; $username = username $password = password ? thanks, T Quote Link to comment https://forums.phpfreaks.com/topic/190354-noob-help-to-extract-username-and-password-from-api-reply/ Share on other sites More sharing options...
wildteen88 Posted January 30, 2010 Share Posted January 30, 2010 If the username and password are separated by a comma use explode Example: $text = 'username,password'; list($username, $password) = explode(',', $text); echo 'Username is: ' . $username . '<br />'; echo 'Password is: ' . $password; Quote Link to comment https://forums.phpfreaks.com/topic/190354-noob-help-to-extract-username-and-password-from-api-reply/#findComment-1004222 Share on other sites More sharing options...
dpacmittal Posted January 30, 2010 Share Posted January 30, 2010 Please post the reply with changed username and password. You can use preg_match to get username and password. Quote Link to comment https://forums.phpfreaks.com/topic/190354-noob-help-to-extract-username-and-password-from-api-reply/#findComment-1004309 Share on other sites More sharing options...
thernes Posted January 30, 2010 Author Share Posted January 30, 2010 @wildteen88 Thanks. I'll give it a try @dpacmittal I'm sorry, but I am not sure what you mean? What do you want me to post? Quote Link to comment https://forums.phpfreaks.com/topic/190354-noob-help-to-extract-username-and-password-from-api-reply/#findComment-1004364 Share on other sites More sharing options...
thernes Posted January 30, 2010 Author Share Posted January 30, 2010 Looks like your solution works just like I wanted it to do, wildteen88. Thanks a bunch Quote Link to comment https://forums.phpfreaks.com/topic/190354-noob-help-to-extract-username-and-password-from-api-reply/#findComment-1004425 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.