私は提供するIDに基づいてapiを呼び出し、配列にデータを返すcURL関数を持っています。これまでのところすべてが完璧に機能します。私は何をしたいと把握することはできません、このです:json配列レスポンスを取得して別の配列に格納する
私はすべての注文は、foreachの内部でこのカールを入れて、に基づいて、各列に追加する
@foreach($orders as $order)
$order->address
$order->time_created
$order->price
... etc
@endforeach
ことが可能ですがうそのテーブルで表示しますforeachを持っています$order->order_id
アレイからさらにデータを表示するには?
したがって、このような何か
@foreach($orders as $order)
$order->address
$order->time_created
$order->price
... etc
$url = get_curl_content_tx("http://example.com/".$order->order_id);
$data = json_decode($url,true);
@foreach ($data as $moreData)
@if ($moreData['data'] == $order->time_created)
// show something
@else
// show other thing
@endif
@endforeach
@endforeach
私の問題は、私は私が
$url = get_curl_content_tx("http://example.com/1");
$url = get_curl_content_tx("http://example.com/2");
$url = get_curl_content_tx("http://example.com/3");
$url = get_curl_content_tx("http://example.com/4");
$url = get_curl_content_tx("http://example.com/5");
$url = get_curl_content_tx("http://example.com/6");
すなわち、すべてのorders_id
を得ることができるので、それでは、私は私のif/else
を行うことができますどのようにループのURLを把握することはできませんということですブロック。私が使用するフレームワークはLaravel 4.2です。
私は達成したいことが十分にはっきりしていることを願っています。ではない場合、私は物事をクリアしようとします。..
EDIT:例それがどうあるべきか:
<table>
<thead>
<tr>
<th class="text-center">#</th>
<th class="text-center">Date Created</th>
<th class="text-center">Name</th>
</tr>
</thead>
<tbody>
<tr>
<th>1</th>
<th>$url = get_curl_content_tx("http://example.com/1")</th>
<th>Product 1</th>
</tr>
<tr>
<th>2</th>
<th>$url = get_curl_content_tx("http://example.com/2")</th>
<th>Product 2</th>
</tr>
</tbody>
</table>
におけるエコーせずにはい、それは可能です短いバージョンです。それでもあなたの問題は何か分かりません。 – Suraj
私の問題は、私がループトラフの注文とページ上で10オーダーです。その後、同じorder_idで10回のカールURLを取得しました。つまり、最初のURLです。 – Garg
foreach内でCURLリクエストを実行したいと思っているから、CURLはforeachの値に依存します。しかし、CURLが同じorder_idで実行されているとしますか?あなたが表示したコードが正しい場合(つまり '@foreach($ orders as $ order)'と各 '$ order-> order_id'が異なる場合、それは正しく動作するはずです...詳細を提供できますか? –