dongsibao8977 2017-03-30 16:00
浏览 24
已采纳

我可以创建一个PhP数组,然后使用数组名称来创建一个新数组吗?

Sorry for the bad title but I couldn't figure out how to word my question and I couldn't find the answer anywhere.

Can I do this/will this work:

<p>
 <?php
  $x=array(1,2);
  $y=array(3,4);
  $z=array($x,$y);  <-----will this work?
 ?>
</p>
  • 写回答

1条回答 默认 最新

  • douliang9057 2017-03-30 17:45
    关注

    You are actually creating a multi dimensional array here.

    $x = array(1, 2);
    $y = array(3, 4);
    $z = array($x, $y);
    

    The third array will be like this after execution of above script.

    $z = array(
        0 => array(
            0 => 1,
            1 => 2
        ), 
        1 => array(
            0 => 3,
            1 => 4
        ), 
    ) ;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao
  • ¥20 Vite 打包的 Vue3 组件库,图标无法显示
  • ¥15 php 同步电商平台多个店铺增量订单和订单状态