So I have a PHP variable that's value get's replaced from another PHP file. Example:
$var = "~~~OtherVariable~~~";
If I echo this variable out, it prints out the appropriate string. Example:
echo $var; //prints out "This is a string of text";
So it looks like everything is working thus far, my PHP variable ($var
) shows that it actually contains the string "This is a string of text"
and not "~~~OtherVariable~~~"
.
Now here comes the problem, I want to use this PHP variable in another PHP function I have else where (on the same page), I want the variables ($var
) value to be "This is a string of text"
, but instead the function is reading it as "~~~OtherVariable~~~"
, which is not what I want!
Is there a way to make the function read the variable as "This is a string of text"
instead of "~~~OtherVariable~~~"
??
Thanks Guys & Gals
EDIT: Here's the chunk of code:
$string = "~~~ItemTitle~~~"; /*Another php file looks for any string in
this file with "~~~ItemTitle~~~" and replaces it with another block of
text, ie. "This is a string of text, http://www.google.ca" */
//Then I have a little function to look for any links inside of a string of text
function do_reg($text, $regex)
{
preg_match_all($regex, $text, $result, PREG_PATTERN_ORDER);
return $result[0];
}
$regex = '\b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]';
$regex = '$'.$regex.'$i';
$A =do_reg($string, $regex); /* This is where I tell it what string I want
it to look into for any URL's */
foreach($A as $B)
{
echo "$B<BR>"; //Prints out just the URL
}
But when I tell it too look in the $string
variable it reads it as "~~~ItemTitle~~~"
and not the string of text it gets replaced as.