I've been struggling with this for a while.
Here's what I'm trying to do:
private function makeMiniTemplat e($ARRAY){
/*
$ARRAY looks like this:
$ARRAY['h']='Some Value';
$ARRAY['mce']='Something else';
*/
$template=<<<al lthis
<div>[h]</div>
<div>[mce]</div>
....
allthis;
/*
I want to replace [h] with $ARRAY['h'];
Drives me crazy not to be able to use nowdocs in classes but that's
another story...
*/
$template=preg_ replace_callbac k(
"/\[(.*?)\]/s",
create_function ('$matches','ec ho $ARRAY[$matches[1]];'),
$template);
return $template;
}
So, I don't know how to pass in $ARRAY as $ARRAY is not "scoped" inside
the create_function . It always comes up empty.
I don't see how to do this using callbacks either. I'm a little short of
understanding on how this works. I've tried a number of different
approaches.
How do I do this?
Jeff
Here's what I'm trying to do:
private function makeMiniTemplat e($ARRAY){
/*
$ARRAY looks like this:
$ARRAY['h']='Some Value';
$ARRAY['mce']='Something else';
*/
$template=<<<al lthis
<div>[h]</div>
<div>[mce]</div>
....
allthis;
/*
I want to replace [h] with $ARRAY['h'];
Drives me crazy not to be able to use nowdocs in classes but that's
another story...
*/
$template=preg_ replace_callbac k(
"/\[(.*?)\]/s",
create_function ('$matches','ec ho $ARRAY[$matches[1]];'),
$template);
return $template;
}
So, I don't know how to pass in $ARRAY as $ARRAY is not "scoped" inside
the create_function . It always comes up empty.
I don't see how to do this using callbacks either. I'm a little short of
understanding on how this works. I've tried a number of different
approaches.
How do I do this?
Jeff
Comment