You are here: Re: Parsing and replacing in PHP « PHP Programming Language « IT news, forums, messages
Re: Parsing and replacing in PHP

Posted by Stephen Kay on 03/22/06 04:00

in article 1142986667.329786.202020@i39g2000cwa.googlegroups.com, bobzimuta
at ejmalone@gmail.com wrote on 3/21/06 7:17 PM:

> Easiest way is to use a perl regular expression search and replace.
>
> Something like this?
>
> http://em.hopto.org/code/test/test_preg.php
>
> I'm feeling nice (and bored) today :-)
>


Thanks, that was helpful for the thing that I am working on, too.

However, maybe you can answer this - if I have a string formatted into a
variable, say $strip_it, which is:

$strip_it = "http://www.someaddress.com/somepage";

....and I wanted to strip this out of a whole page of code where it appeared
multiple times, how would you set the values?


From your example (note I am using PHP 4.4, so no count parameter):


  $search  =  $strip_it;
  $replace = ""; // replace with nothing
  
  $result = preg_replace( $search, $replace, $initial_html, -1, );

I can't figure out how to set up $search - I keep getting different
errors...

--
Stephen Kay
Karma-Lab sk@karma-lab.NOSPAM.com
^^^^^^^

 

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

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