Is there a way in PHP to only echo the integers from a variable?
For example say I had this piece of code:
$variable = "something123";
How would I echo out only the “123”?
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.
You should use a regular expression for this.
The
$matchvariable is filled with the first numerical part of the string you pass to thepreg_matchfunction.\d+means “1 or more digits”