Help with 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
whizzfrapp
Forum Newbie
Posts: 1
Joined: Sat May 16, 2009 5:38 pm

Help with array

Post by whizzfrapp »

Is there any way to use the keys that i want in a keyed array?
I'm doing this but it gives me an error

Code: Select all

 
$result = db_query('SELECT * FROM {team}');
  
  $rows = array();
  
  while ($team = db_fetch_object($result)) {
    array_push($rows, $team);
  }  
  
  $check = array();
  
  foreach($rows as $team)
  {
     $id = $team->team_id;
     $name = $team->name;
     array_push($check, $id => t($name));
  }
Last edited by Benjamin on Sat May 16, 2009 6:18 pm, edited 1 time in total.
Reason: Changed code type from text to php.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Help with array

Post by Darhazer »

What error give you this?
And you have a function called 't' defined?

P.S.
The last line probably should be:

Code: Select all

array_push($check, array($id => t($name)));
Post Reply