字符串数组一一打印

时间:2019-08-07 06:46:56

标签: php

 return res.status(200).json({status: true, data: allShipments, errors: null, msg: "All Shipments fetched successfully"});

3 个答案:

答案 0 :(得分:3)

更新

如果要生成其他输出,下一个示例可能会有所帮助:

PHP:

<?php
$products = array(
    '12,11,10',
    '16,15,14',
    '600,103,20'
);

$output = array();
foreach($products as $product) {
    $a = explode(',', $product);
    foreach ($a as $key => $value) {
       $output[$key][] = $value; 
    }
}

foreach($output as $line) {
   echo implode(' ', $line)."<br>"; 
}
?>

输出:

12 16 600 
11 15 103 
10 14 20 

原始答案:

下一个示例演示了两种从阵列获取输出的可能方法。

PHP:

<?php
$products = array(
    '12,11,10',
    '16,15,14',
    '600,103,20'
);

// Complex approach
foreach($products as $product) {
    $a = explode(',', $product);
    foreach ($a as $value) {
       echo $value." "; 
    }
    echo "<br>";
}

// Simple approach
foreach($products as $product) {
    echo $product."<br>";
}
?>

输出:

12 11 10 
16 15 14 
600 103 20 
12,11,10
16,15,14
600,103,20

答案 1 :(得分:1)

请参见下面的代码。

$products = array ( 
    '0' => '12,11,10', 
    '1' => '16,15,14', 
    '2' => '600,103,20' 
);

$productIds = array();
$productWeights = array();
$productQuantities = array();

foreach( $products as $k => $v ) {
    $line = explode(',', $v );
    $productIds[] = $line[0];
    $productWeights[] = $line[1];
    $productQuantities[] = $line[2];
}

echo implode( ' ', $productIds);
echo '<br />';
echo implode( ' ', $productWeights);
echo '<br />';
echo implode( ' ', $productQuantities);
echo '<br />';

答案 2 :(得分:1)

使用Outlook.OlRecurrenceState rState = appointmentItem.RecurrenceState; if (rState == Outlook.OlRecurrenceState.olApptMaster) return; appointmentItem.Open += AppointmentItem_Open; (appointmentItem as Microsoft.Office.Interop.Outlook.ItemEvents_10_Event).Close += ThisAddIn_Close; array_map()可以轻松完成。示例:

implode()

Working demo.