🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.php
Article #1307

tablice i usuwanie elementow

#1307
From: Marcin
Date: Mon, 27 Aug 2001 14:35
19 lines
1492 bytes
otoz tak - musze usunackonkretna wartosc (okreslona kluczem
nieliczbowym) z tablicy
niestety php nie ma funkcji w stylu delete($tablica,$klucz) a
array_splice usuwa tylko po indeksie liczbowym
wyjsciem wiec jedynym wydaje sie zrobienie tego
w petli foreach z dodatkowym licznikiem
w stylu:
<?
$klucz="b"; // klucz do usuniecia
$tablica=("a"=>"jeden","b"=>"dwa","c"=>"trzy");
$i=0;
foreach($tablica as $key)
    if($key==$klucz) { $tablica=array_splice($tablica,$i-1,-1); } else { $i++; }
?>

i teraz pytanie - czy da sie jednak jakos skasowac ta wartosc bez uzycia
petli?

Marcin
Technical Details
Message-ID: <9mdlp2$svd$1@news.tpi.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!news.man.poznan.pl!fargo.cgs.poznan.pl!news.internetia.pl!newsfeed.tpinternet.pl!news.tpi.pl!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!news.man.poznan.pl!fargo.cgs.poznan.pl!news.internetia.pl!newsfeed.tpinternet.pl!news.tpi.pl!not-for-mail
From: "Marcin" <marcin@sdi.pl>
Newsgroups: pl.comp.lang.php
Subject: tablice i usuwanie elementow
Date: Mon, 27 Aug 2001 16:35:56 +0200
Organization: tp.internet - http://www.tpi.pl
Lines: 22
Message-ID: <9mdlp2$svd$1@news.tpi.pl>
NNTP-Posting-Host: pa154.pradnik-czerwony.sdi.tpnet.pl
X-Trace: news.tpi.pl 998922850 29677 217.96.219.154 (27 Aug 2001 14:34:10 GMT)
X-Complaints-To: usenet@tpi.pl
NNTP-Posting-Date: 27 Aug 2001 14:34:10 GMT
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MSMail-Priority: Normal
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit