in a php page, it gets data from mysql db like this: <object type="asd" class="dfdf" width="{width}" height="{height}" name="fdf"></object> now i want my php page, replace those {width} & {height} which r already declared in that php file as $width=100 $height=100
<object type="asd" class="dfdf" width="<?php echo $width;?>" height="<?php echo $height;?>" name="fdf"></object> PHP: The above should work if not try this... <object type="asd" class="dfdf" width="'.$width.'" height="'.$height.'" name="fdf"></object> PHP:
haha no man. thats not i wanted. it is {width} & i hav to use it...not those things by the way....str_replace is the solution...hitted my mind after opening this thread
http://www.silveragesoftware.com/handytools.html maybe you can use for your templates this program. find replacer for many files.
something like this? $template = <= Data from the database $template = str_replace("{width}",$width,$template); $template = str_replace("{height}",$height,$template); PHP: str_replace work with arrays too: $template = <= Data from the database $search = array{"{width}","{height}"}; $replace = array{$width,$height}; $template = str_replace($search,$replace,$template); PHP: