【发布时间】:2021-03-05 20:21:45
【问题描述】:
所以,我想使用 PHP 从与客户的数组中生成 CSV 文件。我已经创建了 CSV 标头('Name','Surname,'Email')。
$customers = array(
array('id_client' => '15', 'name' => 'Michael', 'surname' => 'Andrew', 'email' => 'and@gmail.com', 'is_demo' => '1','introduction' => '0'),
array('id_client' => '16', 'name' => 'Oliver', 'surname' => 'Jake', 'email' => 'oliverj@gmail.com', 'is_demo' => '1','introduction' => '0'),
array('id_client' => '8', 'name' => 'Noah', 'surname' => 'James', 'email' => 'njam@gmail.com', 'is_demo' => '0','introduction' => '0'),);
foreach ($customers as $row =>$key) {
我将其设为 foreach,但我不知道如何为这个数组设置一个条件,只有姓名、姓氏、电子邮件以及 is_demo '1' 的含义。
【问题讨论】:
-
你可以使用fputcsv
-
您将使用“if”语句作为条件。有关您正在尝试做的事情的更多详细信息会有所帮助。
-
我想用 fputcsv 传递 csv 文件中的名称、姓氏、电子邮件以及谁拥有 is_demo '1'