Article View: pl.comp.lang.php
Article #219829Re: jak uproscic funkcje
From: lamer
Date: Thu, 23 Jul 2009 07:13
Date: Thu, 23 Jul 2009 07:13
32 lines
1568 bytes
1568 bytes
Kodu troche duzo, ale powinno byc szybkie dla stringow w kodowaniu 8bit, np.
ISO 8859-2. Nie testowalem.
function fajowe($str)
{
$dobre = { tutaj trzeba wpisac cala tablice ASCII- #0- #255, nastepnie
wybrane literki zamienic na odpowiednie, np.
Ę na e, ę na e, ! czy ? na spacje itd.}
$len = strlen($str);
for ($i=0; $i<$len; $i++)
{
$str[$i] = $dobre[$str[$i]];
}
//teraz musimy zamienic wielokrotne spacje na pojedyncze _
$out = $str[0];
for ($i=1; $i<$len; $i++)
{
if ($str[$i] == ' ')
{
if ($str[$i-1] != '') $out .= '_';
}
else
{
$out .= $str[$i];
}
}
return trim($out, '_');
}
lamer
Technical Details
Message-ID:
<h492ng$g7t$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:
<h46fn3$5df$1@news.onet.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: "lamer" <lamer@pl.pl> Newsgroups: pl.comp.lang.php Subject: Re: jak uproscic funkcje Date: Thu, 23 Jul 2009 09:13:39 +0200 Organization: TP - http://www.tp.pl/ Lines: 33 Message-ID: <h492ng$g7t$1@atlantis.news.neostrada.pl> References: <h46fn3$5df$1@news.onet.pl> NNTP-Posting-Host: abyu26.neoplus.adsl.tpnet.pl Mime-Version: 1.0 X-Trace: atlantis.news.neostrada.pl 1248333360 16637 83.9.40.26 (23 Jul 2009 07:16:00 GMT) X-Complaints-To: usenet@news.neostrada.pl NNTP-Posting-Date: Thu, 23 Jul 2009 07:16:00 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit