Re: preg_replace and eval

From: Date: Mon, 28 Oct 2002 10:30:25 +0000
Subject: Re: preg_replace and eval
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-121681@lists.php.net to get a copy of this message
try splitting it first to get several strings into one array, then loop the array and replace its each element concatenating the strings. This is how my mind can process it so far :) -- Maxim Maletsky maxim@php.net www.PHPBeginner.com // PHP for Beginners www.maxim.cx // my Home // my Wish List: ( Get me something! ) http://www.amazon.com/exec/obidos/registry/2IXE7SMI5EDI3 "Daniel Pupius" <dan.pupius@actelearning.com> wrote... : > Hey there, > > We have a class that sets up a tree structure that represents an e-learning > object made up of nested "components". We have a function > getPropertyValue($name) which returns the property $name for the current > component. > > Now, we want to allow the user to use something like {parent.property} in a > property value, so that it can inherit parts of properties from the parent > component. For example: caption = "the name of this component's parent is > {parent.name}!" > > The following line sort of works: > $retVal = > > preg_replace("/(.*){parent.(.*)}(.*)/e","'\\1'.\$this->parentNode->getProper > tyValue('\\2').'\\3'",$retVal); > > However, if there are more than one string to replace it only works on the > last one. So: > caption = "the parent's coordinates are ({parent.left}, {parent.top})" would > only return something like: "the parent's coordinates are ({parent.left}, > 100)" > > Hope someone can help. > > Thanks > > Dan > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#121681) next »