Hello, Given the following strings: 4,15,21,27,30,57,75,78,83 4,20,21,31,75,78 4,14,15,21,27,30,57,75 How would I find the first number in each of them which isn't a 4 or 15? I'll always know which numbers I don't want, but I won't know what numbers will be in each string. It's also possible some of the strings will have neither a 4 or 15 in them. Thank you!
I'd explode them into arrays and then foreach through the arrays until I have a "winner", then break to get out. even pass the string to a function to do the work to make it tidier.
preg_replace where those numbers are at the start of the string "^(4|15)," - in the middle of the string, ",(4|15)," - at the end of the string, ",(4,15)$" - then just explode on , and take the first value.