Array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Array

Post by Shendemiar »

I have a result like this:

Code: Select all

<?php
    while ($rivi = mysql_fetch_array($query, MYSQL_ASSOC))
    {
    $ID = ($rivi['teksti_id']);
    $S  = htmlentities($rivi['suomeksi']);
    $R  = htmlentities($rivi['ruotsiksi']);

    XXX
    }
?>
What suhould i put to XXX to get array with $ID as index, then both $S and $R for each index identified with, say S and R?

feyd | do not disable bbcode when you want to post code
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

$whatever[$ID] = array('S'=>$S, 'R'=>$R);
:roll:
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

if i didn't misunderstand you this would help:

Code: Select all

<?php 
while ($rivi = mysql_fetch_assoc($query)) 
{ 
$ID[$rivi['teksti_id']]['S']= htmlentities($rivi['suomeksi']); 
$ID[$rivi['teksti_id']]['R'] = htmlentities($rivi['ruotsiksi']); 
} 
?>
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

Thanks, yes, i noticed the bbcode issue and fixed it while you were ansvering.
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

oops! ;) feyd you are the fastest around here man :P
jabbaonthedais
Forum Contributor
Posts: 127
Joined: Wed Aug 18, 2004 12:08 pm

Post by jabbaonthedais »

Does feyd even sleep?


feyd | very little :D
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Thank god someone else asked that! I was sitting hear typing my reply and I find out feyd already did reply. Although, in this case it was a good thing because it sounds like I misunderstood the question so I wouldn't have answered it accurately. Darn.
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

:lol: this is another point of view ;)
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

jabbaonthedais wrote:Does feyd even sleep?


feyd | very little :D
Actually there have been a time or two when I was working really late at night and Feyd wasn't there immeadiately. Hail Feyd!
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

nigma wrote:Thank god someone else asked that! I was sitting hear typing my reply and I find out feyd already did reply. Although, in this case it was a good thing because it sounds like I misunderstood the question so I wouldn't have answered it accurately. Darn.
Yeah. It was FAST, and Simple, and Presice. Amazing forum this is. I've never been treated here with disrespect even thou sometimes i'm having hard time trying to make myself understood or then i just ask stupid things in the wrong place. I've allways gotten an answer that satisfied me. HAIL! Long live the... what's this places's name?
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

lol. glad you like it, you should stick around.
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

I have the same thoughts with Shenemiar. It's very cool to be here :) Every question that i couldn't find an answer to -> comes here & get solved!!
Post Reply