array轉換問題

接到下的值

Array ( [5] => 534 [6] => 555 [14] => 568 [67] => 1004 [66] => 577 )

要怎麼轉換成底下這樣?

$test=Array (534 ,555,568 ,1004, 577 )

評論

  • 你的意思
    昰這樣嗎?
    $a = Array (5 => 534,6 => 555,14 => 568,67 => 1004,66 => 577 );
    $test = Array ($a[5],$a[6],$a[14],$a[67],$a[66]);
  • 對!另外想問假設裡面都空值

    $a =Array ( [5] => [6] => [14] => [67] => [66] => )

    要如何判別空值時不能執行?
  • edited 十二月 2014
    這樣嗎?


    $result = Array ( '5' => 534, '6' => 555, '14' => 568, '67' => 1004, '66' => 577 );
    $temp_arr =array();
    $result_temp = Array ( 534, 555, 568, 1004, 577 );
    foreach( $result as $key => $value )
    {
    array_push( $temp_arr , $value);
    }
    var_dump($temp_arr);
    var_dump($result_temp);
  • 類似這樣
    $a = Array(5=>\"\");
    if(!empty($a[5])){
    $test = Array ($a[5]);
    }

  • edited 十二月 2014

    $source = array ('5' => 534 ,'6' => 555 ,'14' => 568, '67' => 1004 ,'66' => 577 );
    $target = array_values($source);

    以上.......
Sign In or Register to comment.