You are here: Re: looping through text with array_key_exists function « All PHP « IT news, forums, messages
Re: looping through text with array_key_exists function

Posted by drako on 10/10/02 11:51

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация