call php function from HTML string
<p>I'm facing a problem to call PHP function from html code and fill arguments of function. 
After that the HTML code is output with returned values of functions.</p>

<p>for an example:</p>

<p>somewhere  In PHP file are defined functions</p>

<pre><code>function html_field($type,$name,$value){ 
//some code here
return $out;
}
// or other example function
function boldme($text){
return "&lt;b&gt;$text&lt;/b&gt;";
}
</code></pre>

<p>After that is generated html output in string with php functions inside (like tags) </p>

<p>HTML String:</p>

<p><code>$html = "&lt;h1&gt;&lt;label for="foo"&gt;{call~html_field("text","name","value")} &lt;/label&gt;&lt;input type="text" name="foo" id="foo" /&gt; &lt;/h1&gt;"</code></p>

<p>OR</p>

<p><code>$html = "&lt;h1&gt;&lt;label for="foo"&gt;{call~boldme("text")} &lt;/label&gt;&lt;input type="text" name="foo" id="foo" /&gt; &lt;/h1&gt;"</code></p>

<p>The solution should ends, like:</p>

<p><code>$html = "&lt;h1&gt;&lt;label for="foo"&gt;&lt;input type="text" name="name" ...&gt; &lt;/label&gt;&lt;input type="text" name="foo" id="foo" /&gt; &lt;/h1&gt;"</code></p>

<p>OR</p>

<p><code>$html = "&lt;h1&gt;&lt;label for="foo"&gt;&lt;b&gt;text&lt;/b&gt; &lt;/label&gt;&lt;input type="text" name="foo" id="foo" /&gt; &lt;/h1&gt;"</code></p>

<p>It is required to filter this string...</p>

<p>NOTE:
The string containing the collected html data from  templates and themes,
they are unknowable files with <strong>pure HTML inside</strong>.</p>

<p>I was using <code>preg_replace_callback</code> to create needed functionality, but all gone now, thanks to my boss.... !@#!</p>
