You are here: Re: preg_replace help « All PHP « IT news, forums, messages
Re: preg_replace help

Posted by robert on 04/25/06 19:39

| preg_replace(/u=/(\d+), 'user='.$user_array["$1"], $buffer)
|
| where $1 is back reference integer found in the search. Does that
| clear things up? Thanks for the help!

preg_replace doesn't work that way. what you could do though, is enumerate
your user array and replace from there.

$users[23] = 10242;
foreach ($users as $systemA => $systemB)
{
preg_replace('/u=([\s"\'])' . $systemA . '\\1/', 'user=' . $systemB,
$buffer);
}

i haven't checked the accuracy of the expression but, i think you get the
idea...based on your criteria, even if preg_replace could do what you hint
at in your example, you'd be setting systemA user id's to blank where there
is no corresponding systemB user match...unless that's a desirable
side-effect. the above just wants systemA to either be surrounded by a
space, quote, or tic on either side of the value. however you fix this, the
above will only be replacing as many users as needed...your 15% or so.

hth,

me

 

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

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