I want to replace several strings in an iteration pattern.
foreach (self::model()->findAll($q) as $ruleSet) {
$stringSet =$ruleSet->logic; // It gives as "1 AND 2"
$dataset = array ();
foreach (CampaignAutoLogic::model()->findAll($q) as $rule) {
$operator = $rule->operator;
$value = $rule->value;
$condition = sprintf(5, $operator , $value); // 5>3 (firs_iter), 5<0
$w= str_replace($rule->id, $condition, $stringSet); // $rule->id first loop gives the value as 1 , second loop the value is 2
$stringSet=$w;
}
}
$this->logger->debug($stringSet);
If I am execute the above code It is not giving as (5>3 AND 5<0). I know I have to take the all $condition out and have replace the $stringSet at once. But don't know how to do them. help me