簡體   English   中英

在PHP中將數組轉換為html表

[英]Convert Array to html table in php

我有一個API生成的數組我使用cpanel托管與PHP 5.6。

我嘗試了很多組合,但沒有工作

該陣列由emag marketplace api生成。

代碼看起來像

 Array ( [isError] => [messages] => Array ( ) [results] => Array ( [0] => Array ( [vendor_name] => WISE COMPUTER SRLD [id] => 2003677675 [parent_id] => [date] => 2017-05-21 10:55:18 [payment_mode] => RAMBURS [payment_mode_id] => 1 [delivery_mode] => CURIER RO [observation] => [status] => 4 [payment_status] => 0 [customer] => Array ( [id] => 994041 [mkt_id] => 994041 [name] => Cristina Manuela Dancas [company] => Cristina Manuela Dancas [gender] => [phone_1] => 0743073616 [phone_2] => [phone_3] => [registration_number] => [code] => [email] => [billing_name] => [billing_phone] => [billing_country] => RO [billing_suburb] => Bucuresti [billing_city] => Sectorul 1 [billing_locality_id] => 2 [billing_street] => Str. Aviator Sanatescu nr. 57, parter, Ap1 [billing_postal_code] => [shipping_country] => RO [shipping_suburb] => Bucuresti [shipping_city] => Sectorul 1 [shipping_locality_id] => 2 [shipping_postal_code] => [shipping_contact] => Cristina Manuela Dancas [shipping_phone] => 0743073616 [created] => 2017-05-21 10:55:19 [modified] => 2017-05-21 10:56:21 [bank] => [iban] => [legal_entity] => 0 [fax] => [is_vat_payer] => 1 [liable_person] => [shipping_street] => Str. Aviator Sanatescu nr. 57, parter, Ap1 ) 

我用什么來轉換HTML表格。

需要一些幫助。 如果您需要更多信息,請留言。

這是我從PHP數組制作HTML表的快速解決方案。 然而,本質是,二維數組,成為一個有意義的表。 您的數組似乎更復雜,因此轉換為有用的表可能需要更多的努力。

    $data = array(  array("ID","Firstname","Lastname","Phone"),
                    array("1","John","Jenkins","+91375953"),
                    array("2","Eduard","Kenny","+7244277"),
                    array("3","Anita","Beaumont","+427427427"),
                    array("4","Wanda","Wade","+274274247"),
                    array("4","Sarah","Colon","+835835"),
                );


    echo '<table border="1">';
    foreach($data as $row) {
        echo '<tr>';
        foreach($row as $cell) {
            echo '<td>'.$cell.'</td>';
        }
        echo '</tr>';
    }
    echo '</table>';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM