0

I have the following code being shown in a textbox and am turning it into a table:

foreach([-Order Detail List([-Order Id-])-]){{
   [-order_detail_id-]
   [-order_id-]
   [-account_id-]
   [-order_detail_assigned-]
}}

I'm doing the replace callback with this function:

preg_replace_callback('/(foreach)\(.*?\).*?\}\}/is', array($declaration, 'GetListPlaceholderConverter'), $email_body);

In the logic I have:

$x = 0;
foreach($matches as $match){
 $x++;
}
return $x;

$x keeps returning 2 even though it should be one.... Whats wrong with my callback?

var_dump($matches) is returning:

array(2) { [0]=> string(153) "foreach([-Order Detail List([-Order Id-])-]){{ 
[-order_detail_id-] 
[-order_id-] 
[-account_id-] 
[-order_detail_assigned-] 
}}" [1]=> string(7) "foreach" }

How is that 2nd string getting in there?

4

0 回答 0