preg_match( "|<!-- InstanceBegin(. *)(-->)(.*)<!-- InstanceEnd -->|U",
$contents, $matches );
$my_template = $matches[0];
preg_match_all( "|<!-- InstanceBeginEd itable(.*)(-->)(.*)<!--
InstanceEndEdit able -->|U", $my_template, $editables );
$keys = array_keys( $editables[1] ); // from the editable region
names
foreach ($keys as $key)
{
$k = trim( ereg_replace( '["]', "", $key ) );
$on_mouse_over = "onMouseOver=hi _frame('$k');";
$on_mouse_out = "onMouseout=lo_ frame('$k');";
$on_mouse_click =
"onClick=url_re fresh('?option= com_oscar&task= editarea&area=" .urlencode($k). "');";
$new_contents = "<div id=$k $on_mouse_over $on_mouse_out
$on_mouse_click >". $editables[0][$k] ."</div>";
$pattern = "|<!-- InstanceBeginEd itable(.*)(-->)(.*)<!--
InstanceEndEdit able -->|U";
$placeholder = "<!--%ed".$k."-->";
$replaced_edita bles = preg_replace($p attern, $placeholder,
$my_template);
}
I want to loop through a string and replace the first instance of the
reg with <!--%ed0--> and the second with <!--%ed1--> etc untill the
loop has finished. But when I look at the output, the file is filled
with the last number - any ideas?
thanks
$contents, $matches );
$my_template = $matches[0];
preg_match_all( "|<!-- InstanceBeginEd itable(.*)(-->)(.*)<!--
InstanceEndEdit able -->|U", $my_template, $editables );
$keys = array_keys( $editables[1] ); // from the editable region
names
foreach ($keys as $key)
{
$k = trim( ereg_replace( '["]', "", $key ) );
$on_mouse_over = "onMouseOver=hi _frame('$k');";
$on_mouse_out = "onMouseout=lo_ frame('$k');";
$on_mouse_click =
"onClick=url_re fresh('?option= com_oscar&task= editarea&area=" .urlencode($k). "');";
$new_contents = "<div id=$k $on_mouse_over $on_mouse_out
$on_mouse_click >". $editables[0][$k] ."</div>";
$pattern = "|<!-- InstanceBeginEd itable(.*)(-->)(.*)<!--
InstanceEndEdit able -->|U";
$placeholder = "<!--%ed".$k."-->";
$replaced_edita bles = preg_replace($p attern, $placeholder,
$my_template);
}
I want to loop through a string and replace the first instance of the
reg with <!--%ed0--> and the second with <!--%ed1--> etc untill the
loop has finished. But when I look at the output, the file is filled
with the last number - any ideas?
thanks
Comment