Question: I'm currently looking through the Dajax examples on <http://www.dajaxproject.com/pagination/> and when I execute the Random Number Example and the Simple Form Example, I could see:

[20/Jul/2012 15:06:37] "POST /dajaxice/couch.randomize/ HTTP/1.1" 200 61

[20/Jul/2012 15:06:38] "POST /dajaxice/couch.updatecombo/ HTTP/1.1" 200 438

These information tells me that the corresponding ajax tasks are being executed. Now I'm trying to do the pagination example, but I don't know how to trigger my ajax, there's no onclick or onchange event and it's supposed to load directly when i serve my page. 

When I use a button (onclick event) to invoke my pagination, it worked.

What am I missing here? Thanks.

Answer: 
Use preg\_match\_all with $matches array (third parameter) and then calculate length or array of occurences:

```
$r = "Hello world!%1, abcdef%2, gfgf%14";

$matches = array();
preg_match_all('/\%\d+/', $r, $matches);
echo isset($matches[0]) ? count($matches[0]) : 0;

```
If you will never you use the % sign for anything other than defining a substring in my mind the easiest way is to do this:

```
$pieces = explode('%',$string);
$num_substrings = count($pieces) + 1;

```