Mailinglisten-Archive |
So sprach =BBHans=A0Theo Mislisch=AB am 2001-09-01 um 18:14:29 +0200 :
> Hallo Leute,
>=20
> normal wird ja ein Array so erstellt:
>=20
> $fruechte =3D array("a"=3D>"orange","b"=3D>"apfel");
>=20
> w=E4re diese Schreibweise falsch?
>=20
> $fruechte[a] =3D "orange";
jein. Da greifst Du auf die Konstante mit dem Namen "a" zur=FCck. Diese
kann PHP vermutlich nicht finden, und ersetzt das dann durch den String
a. Richtig ist:
$fr['a'] =3D 'orange';
> 2. wie kann ich mehrere Werte in ein Array schreiben?
>=20
> Index "a" enth=E4lt "frucht" =3D "orange";
>=20
> Ich meine, wenn man eine DB ausliest, hat man ja auch
> mehrere Werte je Zeile.
Ja, in PEARs DB Abstraktion erh=E4lt man z.B. folgendes bei getAssoc():
* For example, if the table "mytable" contains:
*
* ID TEXT DATE
* --------------------------------
* 1 'one' 944679408
* 2 'two' 944679408
* 3 'three' 944679408
*
* Then the call getAssoc('SELECT id,text FROM mytable') returns:
* array(
* '1' =3D> 'one',
* '2' =3D> 'two',
* '3' =3D> 'three',
* )
*
* ...while the call getAssoc('SELECT id,text,date FROM mytable')
* returns:
* array(
* '1' =3D> array('one', '944679408'),
* '2' =3D> array('two', '944679408'),
* '3' =3D> array('three', '944679408')
* )
War's das, was Du wissen m=F6chtest?
Alexander Skwar
--=20
How to quote: http://learn.to/quote (german) http://quote.6x.to (english)
Homepage: http://www.digitalprojects.com | http://www.iso-top.de
iso-top.de - Die g=FCnstige Art an Linux Distributionen zu kommen
Uptime: 3 days 3 hours 6 minutes
php::bar PHP Wiki - Listenarchive