let’s say I have the following string:
danger13 afno 1 900004
using intval() it gives me 13, however, I want to grab the highest integer in the string, which is 9000004, how can I achieve this?
Edit: the string comes in different forms, and I don’t know where the highest number will be.
You’ll need to get all the integers out of the string, then find the biggest…
$maxis now900004.Note that this is very simple. If your string has anything that matches the pattern
\d+(1 or more digits) that you don’t want to match as a separate integer (e.g.43.535would return535), this won’t be satisfactory for you. You’ll need to define more closely what you mean.