I am new in PHP. I found the usage of a simple foreach, but I want more advance. What I done until now. I am using the ''get'' form method to get some data from API integration. This data I transform them to array. Every time I have more arrays. Right now lets say I got 4967 arrays. After maybe I will have less or more.
So I am getting this
1 --> Login
2 --> Position ID
3 --> ....
4 --> ...
..
..
13 --> Margin
14 --> Login number (let's say 2005)
15 --> Position Id number (let's say 100)
So especially I want something like the below. Everytime to create one TR then 13 TH and looping it until the end
<table>
<tbody>
<tr>
<th>Login</th>
<th>Position ID</th>
..
...
<th>Margin</th>
</tr>
<tr>
<th>12435</th>
<th>132321</th>
..
...
<th>2323</th>
</tr>
<tr>
<th>342243</th>
<th>345345</th>
..
...
<th>24324</th>
</tr>
</tbody>
</table>
Please if you have the kindness somehow give me guidelines with code. I am reading for 3 days and trying but unfortunately I can't do this.
The last thing I done in my php code to create the arrays is this
$array = explode('\r\n', $encodejson);
The output is this
array (
0 => '"login',
1 => 'positionId',
2 => 'openTimestamp',
3 => 'entryPrice',
4 => 'direction',
5 => 'volume',
6 => 'symbol',
7 => 'commission',
8 => 'swap',
9 => 'bookType',
10 => 'stake',
11 => 'spreadBetting',
12 => 'usedMargin',
13 => '3004701',
14 => '394254',
15 => '2018-07-19T23:23:53.733',
16 => '1.2495',
17 => 'BUY',
18 => '300000.00',
19 => 'GBPUSD',
20 => '1.36',
21 => '0.00',
22 => 'BOOK_B',
23 => '0.00',
24 => 'false',
25 => '5325.30',
0 - 12 is one tr th 13 -25 is another tr th
This happening until the end (right now let's say I got 2483 arrays with this structure)
LAST UPDATE!!! I done it with this way and worked
$chunks = array_chunk($array, 13);
echo '<table id = "customers">';
foreach ($chunks as $chunk) {
echo '<tr>';
foreach ($chunk as $val) {
printf('<td>%s</td>', $val);
}
echo '</tr>';
}
echo '</table>';
Thanks all guys for the help
var_export($array);