I’m looking for a multi-byte function to replace preg_match_all(). I need one that will give me an array of matched strings, like the $matches argument from preg_match(). The function mb_ereg_match() doesn’t seem to do it — it only gives me a boolean indicating if there were any matches.
Looking at the mb_* functions page, I don’t offhand see anythng that replaces the functionality of preg_match(). What do I use?
Edit I’m an idiot. I originally posted this question asking for a replacement for preg_match, which of course is ereg_match. However both those only return the first result. What I wanted was a replacement for preg_match_all, which returns all match texts. But anyways, the u modifier works in my case for preg_match_all, as hakre pointed out.
Have you taken a look into
mb_ereg?Additionally, you can pass an UTF-8 encoded string into
preg_matchusing theumodifier, which might be the kind of multi-byte support you need. The other option is to encode into UTF-8 and then encode the results back.See as well an answer to a related question: Are the PHP preg_functions multibyte safe?