【问题标题】:how can i use loop in array of array (php)?我如何在数组数组(php)中使用循环?
【发布时间】:2017-11-08 17:37:17
【问题描述】:

我想在 php 的数组数组中使用重复循环(for、while 等...):

      for($x = 0; $x < $arrlength; $x++) {

         $poets = array(
        'keyboard' => array(

            array($saves[$x]) // this is just one array i don't want this !

        ),
    );
$url= "https://api.telegram.org/bot".$token."/sendMessage?
chat_id=".$chat_id."&text=".$text."&reply_markup=".$jsonPoets;
file_get_contents($url);


}

这行不通,我想这样做:

 for($x = 0; $x < $arrlength; $x++) {

         $poets = array(
        'keyboard' => array(

       //i wanna do like this ...

            array($saves[$x])
          //array($saves[$x])
          //array($saves[$x])
                 .
                 .
                 .

        )
    );
$url= "https://api.telegram.org/bot".$token."/sendMessage?
chat_id=".$chat_id."&text=".$text."&reply_markup=".$jsonPoets;
file_get_contents($url);


}

这意味着我想用循环重复在数组中制作多数组。

【问题讨论】:

    标签: php mysql arrays for-loop telegram-bot


    【解决方案1】:
    $poets= array('keyboard' => array());
    for($x = 0; $x < $arrlength; $x++) {
       $poets['keyboard'][] = array($saves[$x]);
    }
    

    像这样?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-03
      相关资源
      最近更新 更多