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

Secure FTP
Hi experts,
There is no SFTP action in MII workbench.
This means it needs developing custo

upload image name with extension using php
hi frds..

<input id="file1" type="file" name="file[]" &a

Passing an array of values From VB6.0 to Oracle PL/SQL Function
Basically we are using VB6.0.

When we try to pass an array from VB6.0 to an Oracle PL/SQL

Delete all files in folder except with certain name
I have a script that I want to delete all files in a folder (taken from a database) except for one n

$variable = $variable
Hello

Sorry if this is a really simple question but I have run out of ideas. Is there a reall

login box shows up again after logging in 2nd login works
Hello,

I am having trouble on my site Lockerz.rack111.com where when you login the login box

Namespace Problem
I'm having problem with a section of code with a variable namespace.

This code works fine:

PHP - MySQL Fail
My PHP code will only execute the first part of my code...

Code: <?php

sessio

Wordpress IE issue
So I am trying to add the background shadow to my wordpress page. It works fine in Firefox but does

ctype() validation - allowing illegal characters
Hello,
I use ctype() to filter and validate a user form. However, I am trying to allow certain c

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