Re: looping through text with array_key_exists function
- From: "drako" <neil@xxxxxxxxxxxxxx>
- Date: 29 Jun 2006 05:40:02 -0700
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
.
- Follow-Ups:
- Re: looping through text with array_key_exists function
- From: Janwillem Borleffs
- Re: looping through text with array_key_exists function
- References:
- looping through text with array_key_exists function
- From: drako
- Re: looping through text with array_key_exists function
- From: drako
- Re: looping through text with array_key_exists function
- From: Janwillem Borleffs
- Re: looping through text with array_key_exists function
- From: drako
- looping through text with array_key_exists function
- Prev by Date: Re: How to format text in a mailto:
- Next by Date: Re: looping through text with array_key_exists function
- Previous by thread: Re: looping through text with array_key_exists function
- Next by thread: Re: looping through text with array_key_exists function
- Index(es):