Check if exist in array (all in foreach) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Check if exist in array (all in foreach) (/showthread.php?tid=63813) |
Check if exist in array (all in foreach) - vertisan - 12-11-2015 Hi! I have little problem. I need to check every row in another array, and if exist - do something. This is my code: PHP Code: <?php $Sekcje = explode( ',', $Detail->SectionsPrefered ); ?> It's display only one '*', but must display for 3 rows (Section1, Section2, Section3) This is the array $Sekcje: PHP Code: array(3) { Where is the problem? RE: Check if exist in array (all in foreach) - pdthinh - 12-11-2015 (12-11-2015, 09:27 AM)vertisan Wrote: Hi! Was it display only one '*' corresponding to the "Section1"? What's your $SectionsList value? RE: Check if exist in array (all in foreach) - InsiteFX - 12-11-2015 Do a var_dump on your details array and make sure you are getting more then just one value. RE: Check if exist in array (all in foreach) - vertisan - 12-11-2015 Var_dump $SectionsList: PHP Code: array(5) { Var_dump $Sekcje: PHP Code: array(3) { RE: Check if exist in array (all in foreach) - pdthinh - 12-11-2015 (12-11-2015, 12:42 PM)vertisan Wrote: Var_dump $SectionsList: It's because you have white-spaces in $Sekcje elements. Trim it can solve the problem. PHP Code: <?php $Sekcje = array_map('trim', explode( ',', $Detail->SectionsPrefered )); ?> |