On Nov 12, 12:44 pm, Stig Manning <[EMAIL PROTECTED]> wrote:
> Hi PHPUG,
>
> I have to get a project completed very shortly and need to set up a
> sprintf style string pattern replace for variables.
>
> For example I need: sprintfVariables('This is an example of:
> %name%',array('name'=>'some script'));
> And be able to replace %name% with the variable in the array defined
> with the key 'name'.
I do something quite similar.
foreach($yourarray as $key=>$var){
$find= '%' . $key . '%';
$message= str_replace($find,$var,$message);
}
--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---