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

first id from db not showing
I have a php script which displays the content of a mysql table as a html table with sorting, delete

SELECT * FROM users WHERE Users are not in Blocked
How do I select all users from users table where there users_id is not stored in the block table

PHP and SMS
Hi all forum members. I am new here and am unsure what category shoild I post this in.
Moderator

Error with login script
I am getting an error with my login script:

Error:
Code: Warning: Cannot modify header inf

Bit manipulation program with binary operations
My homework is to create a program to scan in and add binary numbers and print them like so

RTF fomatting to email content
Im trying to sen an email with content is picked up from a rtf-file (file_get_contents('*.rtf'). Mai

Google voice
I currently have a form in html, but I want it in php so the information is not in the source code.<

Calender Not Opening
The following code is not loading the javascript calender in another window. It's not doing anything

array & querys help/advice.
Ok so here goes , I have a mysql database and basically here's what I need to do.

// foreach

How to convert this array to string
I am having problems converting this array to a string
using print_r($val[1]); I get:
Code: [

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