how i can pass an intege variable to preg_replace
Posted: Wed May 27, 2009 5:53 am
how i can pass a variable containing an integer value to preg_replace.
plz help.
plz help.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
$subj = "hello, here are some nums 12384";
$int = 3;
$patt = "/$int/";
echo preg_replace($patt, "<blah>", $subj);
You may also want to read:Forum Rules wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.
Code: Select all
$subj = "hello, here are some nums 12384";
$int = 3;
$patt = "/$int/";
echo preg_replace($patt, "three", $subj); //"<blah>" replaced with "three"