Use the following syntax for replacing text in mysql:
The syntax of REPLACE is REPLACE(text_string, from_string, to_string)
SELECT REPLACE(‘www.mysql.com’, ‘my’, ‘you');
and result will be:
www.yousql.com
Cheers!
This blog will give you all kind of Open Source help like Drupal, Zend, Symfony, Joomla and Magento.
Monday, 18 October 2010
Friday, 8 October 2010
How to remove hyperlink from a string using php?
<?php
function findAndReplace($arr) {
return '<strong>'.$arr[1].'</strong>';
}
$inputText = 'Why use <a href="#" style="padding-left:5px"> PHP </a>?';
echo "<br />Input is: <br />";
echo $inputText;
$returnText = preg_replace_callback('@<a(?:.*)>(.*)</a>@isU', 'findAndReplace', $inputText);
echo "<br /><br />Output will be: <br />";
echo $returnText;
?>
Input is:
Why use PHP ?
Output will be:
Why use PHP ?
function findAndReplace($arr) {
return '<strong>'.$arr[1].'</strong>';
}
$inputText = 'Why use <a href="#" style="padding-left:5px"> PHP </a>?';
echo "<br />Input is: <br />";
echo $inputText;
$returnText = preg_replace_callback('@<a(?:.*)>(.*)</a>@isU', 'findAndReplace', $inputText);
echo "<br /><br />Output will be: <br />";
echo $returnText;
?>
Input is:
Why use PHP ?
Output will be:
Why use PHP ?
Subscribe to:
Posts (Atom)