I have cURL function which make calls to api based on ID which I provide and return data in array. So far everything works perfectly. What I want and can't figure out is this:
I have foreach which display in table all orders lie
@foreach($orders as $order)
$order->address
$order->time_created
$order->price
... etc
@endforeach
Is it possible to put this cURL inside the foreach and add on each row based on $order->order_id
to show some more data from the array?
So something like this
@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
My problem is that I can't figure how to loop the url so I can get all orders_id
i.e.
$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");
So then I can perform my if/else
block. Framework which I use is Laravel 4.2.
Hope it is clear enough what I want to accomplish. If is not I will try to clear things..
EDIT: Example what it should be:
<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>