Article View: pl.comp.lang.php
Article #219983Re: zmienna w wyrazeniu regularnym
From: ant
Date: Sun, 02 Aug 2009 18:14
Date: Sun, 02 Aug 2009 18:14
22 lines
1493 bytes
1493 bytes
Lech Dubrowski wrote:
>> <?php
>> $zmienna = 'Ala';
> A czy pojdzie takie wyrazenie $regexp = "/(.*){$zmienna}(.*)/"; bo chcialbym
> wybierac cale wiersze z pliku zawierajace te zmienna?
Tak jak już Lemat powiedział, pójdzie, ale zastanów się
czy potrzebujesz do tego wyrażeń regularnych ;)
<?php
$zmienna = 'Ala';
$wiersze = file('plik.txt');
$wynik = array();
foreach($wiersze as $wiersz)
{
if(false !== strpos($wiersz, $zmienna))
{
$wynik[] = $wiersz;
}
}
var_dump($wynik);
?>
Technical Details
Message-ID:
<h54l4q$6go$1@atlantis.news.neostrada.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!newsfeed.neostrada.pl!atlantis.news.neostrada.pl!news.neostrada.pl!not-for-mailReferences:
<h5443f$4qm$1@nemesis.news.neostrada.pl> <h544em$56u$1@nemesis.news.neostrada.pl> <h546pa$5th$1@atlantis.news.neostrada.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!newsfeed.neostrada.pl!atlantis.news.neostrada.pl!news.neostrada.pl!not-for-mail From: ant <ant@nowhere.tld> Newsgroups: pl.comp.lang.php Subject: Re: zmienna w wyrazeniu regularnym Date: Sun, 02 Aug 2009 20:14:16 +0200 Organization: TP - http://www.tp.pl/ Lines: 22 Message-ID: <h54l4q$6go$1@atlantis.news.neostrada.pl> References: <h5443f$4qm$1@nemesis.news.neostrada.pl> <h544em$56u$1@nemesis.news.neostrada.pl> <h546pa$5th$1@atlantis.news.neostrada.pl> NNTP-Posting-Host: 79.189.151.28 Mime-Version: 1.0 X-Trace: atlantis.news.neostrada.pl 1249236954 6680 79.189.151.28 (2 Aug 2009 18:15:54 GMT) X-Complaints-To: usenet@news.neostrada.pl NNTP-Posting-Date: Sun, 2 Aug 2009 18:15:54 +0000 (UTC) User-Agent: Thunderbird 2.0.0.17 (X11/20080927) In-Reply-To: <h546pa$5th$1@atlantis.news.neostrada.pl> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit