You are here: Re: eregi and eregi replace « PHP Programming Language « IT news, forums, messages
Re: eregi and eregi replace

Posted by John Dunlop on 01/11/06 22:25

Nel wrote:

> <?PHP
> $htmlsource = '<img src="pics/hotdog.gif"> text text <img
> src="pics/silly%20sausage.gif"> ';
> eregi('(=")(pics/)([0-9a-zA-Z%/ ]+.[a-zA-z]..)(")',$htmlsource,$imagesintext);
> ?>

[...]

> What I am trying to do is replace all images in the format ="pics/image.jpg"
> with "image.jpg" and at the same time make a list of the files image.jpg.
> The problem is how to pick up ALL the occurances, not just the first???

preg_match_all(). preg_match is described as an alternative to ereg()
and it stops searching after finding one match, so I assume ereg()
stops then too.

http://www.php.net/manual/en/function.preg-match-all.php

> Also how to use replace to remove the pics/ bit of the string.

Replace them with the zero string. preg_replace().

http://www.php.net/manual/en/function.preg-replace.php

--
Jock

 

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

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