|
Posted by Orin on 07/05/07 13:05
Hi,
Here is my task:
- need to get text from a template variable.
For example we have a text with templates "Cars" and "Producers":
"{{Cars|Toyota=blablabla |Moskvitch=blablabla |BMW=blabla ...}}
{{Producers|TableLTD=blablabla |PhoneINC=Developed in 1998 in Kiev,
Ukraine. Phone and INC are partsof altered name PhoneINC etc...}}
{{Producers|TableLTD=babababa |PhoneINC=Since 1997 Kiev was
recotstructed... PhoneINC company established a new lines system
etc...}}"
I have 2 parameters: template name = "Producers" and variable name
"PhoneINC" that means i need to get text between "PhoneINC=" and "}}"
of template "Producers".
Here is some of my thoughts:
foreach ($col_params as $param) //param[0] - variable and param[1]
template name we need to search for
foreach ($content as $templates){//templates is a text where we need
to do search
$template = explode ("}}" , $templates);
foreach( $template as $redo){
$matches2 = Array();
$matches = Array();
$s = eregi("\{\{$param[1].*", $redo, $matches);
//matches[0] = parts of text that contains template with variables
$s = eregi("$param[0] .*", $matches[0], $matches2);
//matches2[0] = parts of text that contains variables with text and
also variables
// that are next after one we searched for, so here is a problem
occurs ???
$cont = explode ("=", $matches2[0]);
}
Please, if anyone can help, give me some advise.
Thank you in advance.
[Back to original message]
|