我想text在循环中存储数组内的所有值,是否可能?谁能给我一个如何做到这一点的暗示?
$('#wa li').each(function (i) {
var text = $(this).text();
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试通过缓存加载 Shopify 产品,并使用 IMRedis::throttle来防止 Shopify 中的速率限制。我的问题是我把所有的获取过程都放在 a 中Batch,它返回一个负数。待处理的作业。
这是我的方法
公共函数加载(请求$请求,样本$样本){
return DB::transaction(function () use ($sample) {
$batch = Bus::batch([])->dispatch();
$since_id = 0;
while ($since_id >= 0) {
$fetchedProducts = (new ShopifyProduct(
$sample->shopify_domain,
$sample->shopify_info['access_token'])
)
->getById($since_id)
->then(function ($data) {
return $data['products'];
}, function () {
return [];
})
->wait();
if (collect($fetchedProducts)->count() == 0) break;
$lastProduct = Arr::last($fetchedProducts);
$since_id = $lastProduct['id'];
collect($fetchedProducts)
->each(function ($shopifyProduct) use($merchant, &$batch) {
$batch->add(new CacheProducts($shopifyProduct, $sample));
});
}
return …Run Code Online (Sandbox Code Playgroud) 我想分解一个字符串或一个整数并用空格分隔。
例如,我有这个 int 12345678,我希望它的数字变成123 45678。我想将前三个数字分开。有人可以给我一个线索或提示如何实现这一点,比如在 PHP 中使用什么函数?我认为使用 anexplode在这里不起作用,因为该explode函数需要一个分隔符。