Jump to content

[SOLVED] tough one -- replace "&" with "&"


michaellunsford

Recommended Posts

I want to search through an array and replace every isolated occurance of "&" with "&" -- the catch is, I don't want to replace encoded characters, like   & etc.

I can build an expression that does the exact opposite -- but having trouble the other way around. Here's "the opposite":

[code]<?php
$blah=array('bob & brenda', 'bob &amp; brenda', 'bob &nbsp; brenda&nbsp;');
do {
echo preg_replace("*&[A-Za-z]{2,4};*","&nbsp;",current($blah))."\n";
}while(next($blah));
?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/33253-solved-tough-one-replace-with-amp/
Share on other sites

  • 1 year later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.