I have array in this format...
[User] => Array
(
[Oct 09] => Array
(
[10] => 1
[8] => 0
[9] => 0
[7] => 0
[6] => 0
)
[Oct 10] => Array
(
[10] => 0
[8] => 1
[9] => 0
[7] => 0
[6] => 0
)
[Oct 11] => Array
(
[10] => 1
[8] => 0
[9] => 1
[7] => 1
[6] => 1
)
)
I want to parse the array without using any loop so that it converts in the form
[User]=>array
(
[0] =>array(
[date] => OCt 09
[user_id] => 10
[attendance] => 1
)
[1] =>array(
[date] => OCt 09
[user_id] => 8
[attendance] => 0
)
)
Like this I dont' want to use foreach or for loop as it take time to parse. I want to use inbuilt array function. What I tried was
public function parseAttendance($y){
return array("date", "user_id", "attendane"); // I want to return something like in this format.
}
public function admin_attendance() {
$result = array_map(array($this, 'parseAttendance'), $arr['User']);
print_r($result);
die();
}
array_map()
please don't forget to check the manual, there are useful examples.foreach
andfor
as these are slower thanarray_map
orarray_walk