Jump to content


Replace varibles


1 reply to this topic

#1 barber84

    Young Padawan

  • Members
  • Pip
  • 8 posts

Posted 02 January 2006 - 06:54 PM

I have a html file that contains varibles in the format #variblename# I know how to load the file into an array in php, but how would i tell the script to search through the array and wherever it finds #variblename# in the array it will change it to <?php print $variblename; ?> think i would have to use str_replace() or something simular wouldnt i?

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 02 January 2006 - 11:08 PM

str_replace would be your best bet. And while you're at it, rather then replacing #var# with <?php print $var; ?> just replace #var# with the value of $var.
i.e.
str_replace('#var#', $var, $html);






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users