I am experimenting with datatables and php, and trying to get an example server side script working at https://www.datatables.net/examples/data_sources/server_side.html.
as part of this I need to create an array of arrays of the datatable columns that looks like:
$columns = array(
array( 'db' => 'first_name', 'dt' => 0 ),
array( 'db' => 'last_name', 'dt' => 1 ),
array( 'db' => 'position', 'dt' => 2 ),
array( 'db' => 'office', 'dt' => 3 ),
);
I have an array:
$mytablescolumns = array('name1','name2', ... )
which I would like to iterate through producing a 2d array that looks like:
$columns = array(
array( 'db' => 'name1', 'dt' => 0 ),
array( 'db' => 'name2', 'dt' => 1 ),
I've looked at http://php.net/manual/en/function.array-fill.php and http://php.net/manual/en/function.array-fill-keys.php , but I'm not sure if these will accomplish this since they appear to deal with 1D arrays. How can I accomplish this?
foreach()loop to do so?