KhanyBoy wrote:
this should test you guru's. I want a function that accepts text as an
argument and converts all & into & except where it is a html
character already such as , ", and of course &.
If there is already a php function for this I would like to know, but
if not, what is the GREP equivilent?
OK, this does that, but it may not be a very elegant soltion. I recently
needed the same functionality for a project involving oscommerce.
function ampersandFix($x){
$x=str_replace('&','&',$x);
$pattern='`&(#[0-9]{2,3}|aacute|acirc|acute|aelig|agrave|amp'.
'|aring|atilde|auml|brvbar|brkbar|ccedil|cedil|cen t'.
'|copy|curren|deg|divide|eacute|ecirc|egrave|eth|e uml'.
'|frac12|frac14|frac34|gt|iacute|icirc|iexcl|igrav e'.
'|iquest|iuml|laquo|lt|macr|hibar|micro|middot|nbs p|not'.
'|ntilde|oacute|ocirc|ograve|ordf|ordm|oslash|otil de'.
'|ouml|para|plusmn|pound|quot|raquo|reg|sect|shy|s up1|sup2'.
'|sup3|szlig|thorn|times|uacute|ucirc|ugrave|uml'.
'|die|uuml|yacute|yen|yuml);`i';
$replace='&$1;';
return preg_reacple($pattern,$replace,$x);
}
--
Justin Koivisto -
sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.