Re: looping through text with array_key_exists function



OK, the suggestion:

print preg_replace('/([a-z0-9])/', '<img src="$1.jpg" />', $text);

works fine, except, as I suspected, it cannot pick up spaces or other
special characters I need to detect.

I thought using "preg_match" would work - i.e.

if(preg_match('/([a-z0-9])/', $text)) {preg_replace('/([a-z0-9])/',
'<img src="$1.jpg" />', $text); }

elseif.....
else....


However, this does not seem to match them, and defaults to the 'else'
clause.


I thought I understood PHP quite well, but obviously not well enough
!!!

Neil.






drako wrote:
Sorry. I will try your solution. I replied to the message when I first
got out of bed this morning (usually not a good idea).

I was just thinking how to capture special characters, as I can't have
files named ' .jpg', '!.jpg', or ".jpg

However, I can capture these with exceptions.

Thanks
Neil.

Janwillem Borleffs wrote:
drako wrote:
I see what you mean - but you can't explode a space, then append
'.jpg' to it - although I'm sure there is a way around this.


Why don't you simply try my solution?


JW

.