2 回答
TA贡献1891条经验 获得超3个赞
我无法完全理解您的问题。但是根据我的理解,您需要这样的输出"Laptop",15000, 100, Baik
<?php
//function Multidimentional Array
function barang (){
$charles = [["nama_barang"=>"Laptop","harga"=>15000,"Qty"=>100,"Kondisi"=>"Baik"],["nama_barang"=>"Dekstop","harga"=>30000,"Qty"=>30,"Kondisi"=>"Buruk"],
["nama_barang"=>"Smartphone","harga"=>40000,"Qty"=>20,"Kondisi"=>"Baik Sekali"]];
return $charles;
}
//Print the result of Multidimentional Array called from function
echo '"' . barang()[0]['nama_barang'] . '" ,' .
barang()[0]['harga'] . ' ,' .
barang()[0]['Qty'] . ' , ' .
barang()[0]['Kondisi'];
?>
TA贡献1856条经验 获得超11个赞
您可以用来array_map在浏览器上打印它们
$charles =
[["nama_barang"=>"Laptop","harga"=>15000,"Qty"=>100,"Kondisi"=>"Baik"],
["nama_barang"=>"Dekstop","harga"=>30000,"Qty"=>30,"Kondisi"=>"Buruk"],
["nama_barang"=>"Smartphone","harga"=>40000,"Qty"=>20,"Kondisi"=>"Baik Sekali"]];
$res = array_map(function($v){
return implode(',',$v); //echo implode(',',$v)
}, $charles);
echo '<pre>';
print_r($res);
- 2 回答
- 0 关注
- 185 浏览
添加回答
举报