$columns = array( 'title', 'client', 'date', 'product', 'status' );
This is print:
Array
(
[0] => title
[1] => client
[2] => date
[3] => product
[4] => status
)
I want to give values for the $columns array to be like this:
Array
(
[title] => Subject
[client] => Requester
[date] => Requested
[product] => Product
[status] => Status
)
I have try to make something like this:
$columns['title'] = 'Subject';
$columns['client'] = 'Requester';
$columns['date'] = 'Requested';
$columns['roduct'] = 'Product';
$columns['status'] = 'Status';
But it's not working it merges the two arrays and print this:
Array
(
[0] => title
[1] => client
[2] => date
[3] => product
[4] => status
[title] => Subject
[client] => Requester
[date] => Requested
[product] => Product
[status] => Status
)
The code that prints the final result is this:
$columns = array( 'title', 'client', 'date', 'product', 'status' );
$columns['title'] = 'Subject';
$columns['client'] = 'Requester';
$columns['date'] = 'Requested';
$columns['roduct'] = 'Product';
$columns['status'] = 'Status';
If i understood you correctly you want to add these data
$data = ['Subject', 'Requester', 'Requested', 'Product', 'Status'];
to the columns name that you mention
$columns = array( 'title', 'client', 'date', 'product', 'status' );
so it would be something like this one
$columns = array( 'title', 'client', 'date', 'product', 'status' );
function prepareArray($columns){
$humansTitles = [
'title' => 'Subject',
'client' => 'Requester',
'date' => 'Requested',
'product' => 'Product',
'status' => 'Status'
];
$res = [];
foreach($columns as $col){
$res[$col] = $humansTitles[$col];
}
return $res;
}
print_r(prepareArray($columns));