I have the following string: a:2:{s:4:”user”;b:1;s:6:”userid”;s:2:”48″;}
What I need to do is extract number 48 from it, in this case. This number could have any number of digits. How would I go about doing this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It looks like you are facing a serialized strings. So, instead of trying to get that number using regular expression or any other string manipulation methods, try this:
Learn about PHP serialization here: