Kazi Nayem Kazi Nayem - 3 months ago 9
MySQL Question

Display Multidimensional array into table row individually in CodeIgniter

I have an array like this (displayed below), I want to display related information individually in a table row which image given below.

Array
(
[recent_task_of_developers] => Array
(
[0] => Array
(
[id] => 1
[name] => Kazi nayem
[project_name] => Array
(
[0] => Array
(
[project_name] => Nayem Book House (BBH)
)

[1] => Array
(
[project_name] => Nayem Book House (BBH)
)

[2] => Array
(
[project_name] => Nayem Book House (BBH)
)

[3] => Array
(
[project_name] => Nayem Book House (BBH)
)

)

)



[2] => Array
(
[id] => 32
[name] => Nayem
[project_name] => Array
(
[0] => Array
(
[project_name] => Nayem - MasForce
)

[1] => Array
(
[project_name] => Nayem - MasForce
)

[2] => Array
(
[project_name] => Nayem
)

[3] => Array
(
[project_name] => Nayem Book House (BBH)
)

[4] => Array
(
[project_name] => Nayem Book House (BBH)
)

[5] => Array
(
[project_name] => Nayem - MasForce
)

[6] => Array
(
[project_name] => Nayem Book House (BBH)
)

[7] => Array
(
[project_name] => Nayem - MasForce
)

[8] => Array
(
[project_name] => Nayem - MasForce
)

[9] => Array
(
[project_name] => Nayem - MasForce
)

[10] => Array
(
[project_name] => - MasForce
)

[11] => Array
(
[project_name] => - MasForce
)

[12] => Array
(
[project_name] => - MasForce
)

[13] => Array
(
[project_name] => - MasForce
)

[14] => Array
(
[project_name] => Nayem - MasForce
)

[15] => Array
(
[project_name] => Nayem Book House (BBH)
)

[16] => Array
(
[project_name] => Nayem Book House (BBH)
)

[17] => Array
(
[project_name] => Nayem Book House (BBH)
)

[18] => Array
(
[project_name] => Nayem Book House (BBH)
)

)

)


I want to display this array like this image in a table.

enter image description here

Answer

Try this:

foreach($recent_task_of_developers as $developers)
{
   foreach($developers as $developer)
   {
       $id = $developer['id'];
       $name = $developer['name'];

       foreach($developers['project_name'] as $projects)
       {
           // $projects['project_name']; will contain the projects name in it
           // put your table html accordingly
       }
   }
}

I think it will solve your problem.

Comments