Welcome Guest, Not a member yet? Register   Sign In
Check if exist in array (all in foreach)
#5

(12-11-2015, 12:42 PM)vertisan Wrote: Var_dump $SectionsList:
PHP Code:
array(5) {
 
 [0]=>
 
 object(stdClass)#33 (3) {
 
   ["ID"]=>
 
   string(1"1"
 
   ["Title"]=>
 
   string(8"Section1"
 
   ["Description"]=>
 
   string(13"Opis sekcji 1"
 
 }
 
 [1]=>
 
 object(stdClass)#34 (3) {
 
   ["ID"]=>
 
   string(1"2"
 
   ["Title"]=>
 
   string(8"Section2"
 
   ["Description"]=>
 
   string(13"Opis sekcji 2"
 
 }
 
 [2]=>
 
 object(stdClass)#35 (3) {
 
   ["ID"]=>
 
   string(1"3"
 
   ["Title"]=>
 
   string(8"Section3"
 
   ["Description"]=>
 
   string(13"Opis sekcji 3"
 
 }
 
 [3]=>
 
 object(stdClass)#36 (3) {
 
   ["ID"]=>
 
   string(1"4"
 
   ["Title"]=>
 
   string(8"Section4"
 
   ["Description"]=>
 
   string(13"Opis sekcji 4"
 
 }
 
 [4]=>
 
 object(stdClass)#37 (3) {
 
   ["ID"]=>
 
   string(1"5"
 
   ["Title"]=>
 
   string(8"Section5"
 
   ["Description"]=>
 
   string(13"Opis sekcji 5"
 
 }


Var_dump $Sekcje:
PHP Code:
array(3) {
 
 [0]=>
 
 string(8"Section1"
 
 [1]=>
 
 string(9" Section2"
 
 [2]=>
 
 string(9" Section3"


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 )); ?>
Reply


Messages In This Thread
RE: Check if exist in array (all in foreach) - by pdthinh - 12-11-2015, 02:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB