why preg_match_all does not return the number of matches


Posted on 16th Feb 2014 07:03 pm by admin

My regex looks like

X[^x{4e00}-x{9fa5}]*Y

(where X and Y are two Chinese characters)

and my expression looks like

preg_match_all("/".$regex."/iu", $content, $out, PREG_PATTERN_ORDER)

it turns out that preg_match_all is always returning 1, even though count($out[0]) is > 1 (and correctly so). So I ended up using count($out[0]) rather than the value this function returns. Though this solves the current issue I need, I am very curious why this is happening. Am I misunderstanding preg_match_all?

I'd greatly appreciate if anyone can point me to the explanation of this problem. Thanks in advance!

No comments posted yet

Your Answer:

Login to answer
333 Like 22 Dislike
Previous forums Next forums
Other forums

Upload file!
Ok i have a form..
Code: <form name="form1" method="post" action=&quo

Beginner question regarding Array's
Hi everyone, the page im working on has an array of variable at the top...

Code: $define_li

newbie question
Hi out thereIm totaly new in this forum and to .net and vb so here is a totaly newbie question.I wan

need help about
i store the value of my select statement result to an array and stored it to a variable named $fname

How a counter of users ? such as ---> (231 Viewing)
I want to count how many users are actually viewing the page, How is that possible?
Thank you guy

Reduce redundancies in switch functions?
Hello all! I somewhat new to PHP, and was wondering if anyone could give some suggestions on a swit

RSS poster script?
I have found a script that posts RSS's for me on a site that I'm building. However I would like to a

Using CSS to format MySQL query
Hi,

If i want to have a news page on my site, which displays all records of a table in descen

add text and number image
hi guys ..

ok see i want the user to add their name and pick a number then click get it and i

Newb advice
Hi all,

I'm a flash front end designer and I've taken on a project that needs some back end p

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash