Create PHP array from MySQL column

前端 未结 11 973
花落未央
花落未央 2020-12-03 07:54

mysql_fetch_array will give me an array of a fetched row. What\'s the best way generate an array from the values of all rows in one column?

11条回答
  •  自闭症患者
    2020-12-03 08:04

    // I'm using this for years and it works very good !! it's easy and logic
    $translate = array();
    
    while ($row = mysql_fetch_assoc($result))
      {
          $cullomnkey = $row['translshort']; // is what you want the key to be 
          $translate[$cullomnkey] = $row[$language]; // this is the key and the value in the array 
      }
    

提交回复
热议问题