How to write this array in loop?
$columns = array(
"name" => 'slider'
, "value" => $user_slider,
"name" => 'welcomebox'
, "value" => $user_welcomebox,
"name" => 'servicebox'
, "value" => $user_servicebox,
"name" => 'postbox'
, "value" => $user_postbox
);
how to write name and value in loop?
Your array is wrong. You mean sub array's. Change your array, like so:
$columns = [
[
'name' => 'slider',
'value' => $user_slider
],
[
'name' => 'welcomebox',
'value' => $user_welcomebox
],
[
'name' => 'servicebox',
'value' => $user_servicebox
],
[
'name' => 'postbox',
'value' => $user_postbox
]
];
So you can loop with foreach:
foreach ($columns as $key => $value) {
echo $key . ': ' . $value . '<br>';
}
Are you wanting an array holding multiple users information or just one user?
You may find it useful to read up on array structure (http://php.net/manual/en/language.types.array.php) to help you move forwards, dumping the array you've created won't give you the results you're looking for.
Here's a correctly structured array which may be what you're after
$columns = array(
'slider' => $user_slider,
'welcomebox' => $user_welcomebox,
'servicebox' => $user_servicebox,
'postbox' => $user_postbox
);