gpt4 book ai didi

hacklang - 如何在hacklang中迭代形状的字段?

转载 作者:行者123 更新时间:2023-12-05 01:09:46 25 4
gpt4 key购买 nike

假设我有这样的形状

$something = shape(
'some_key' => ...,
'another_key' => ...,
...
);

如何迭代形状的每个字段?我正在寻找这样的东西

foreach ($something as $key) {
...
}

最佳答案

先用内置的HH\Shapes::toDict转换成dict然后迭代:

foreach(HH\Shapes::toDict($something) as $k => $v) {
// ...
}

关于hacklang - 如何在hacklang中迭代形状的字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64793229/

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