gpt4 book ai didi

php - 我如何在数组数组(php)中使用循环?

转载 作者:行者123 更新时间:2023-11-29 10:32:14 25 4
gpt4 key购买 nike

我想在 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);


}

这意味着我想在数组中使用循环重复创建多个数组。

最佳答案

$poets= array('keyboard' => array());
for($x = 0; $x < $arrlength; $x++) {
$poets['keyboard'][] = array($saves[$x]);
}

像这样吗?

关于php - 我如何在数组数组(php)中使用循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47186192/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com