nil2567 Posted August 30, 2012 Share Posted August 30, 2012 (edited) ok, I'm trying to do this: foreach($a as $b ){ $c = $b; // if I do an echo here I have string insede $c } $d = 'abcde'.$c // if I do echo here I have the same string inside $d $smarty->assign('url',$d); the result I'm geting is just abcde any idea why? pleaseeee Edited August 30, 2012 by nil2567 (see edit history) Link to comment Share on other sites More sharing options...
coeos.pro Posted August 30, 2012 Share Posted August 30, 2012 $a is an array ? $c = $b not $c .= $b or $c += $b ? Link to comment Share on other sites More sharing options...
nil2567 Posted August 30, 2012 Author Share Posted August 30, 2012 $a is an array. but I discover another problem. the problem is: when i do a scandir I get an array. Ex: $a = scandir($directory); if I now do : $smarty->assign('variable',$a) I don't get nothing in the tpl file and I shoud get array. If I do $smarty->assign('variable',$a.'hello'); I will get outpu of just hello Link to comment Share on other sites More sharing options...
coeos.pro Posted August 30, 2012 Share Posted August 30, 2012 could you give the $a value Link to comment Share on other sites More sharing options...
nil2567 Posted August 30, 2012 Author Share Posted August 30, 2012 a have an string. the name of a file inside directory. It is strenge, I should have an value. if I do an echo inside the funcion i have the value of a to resume, I can't output in tpl the value of a scandir Link to comment Share on other sites More sharing options...
coeos.pro Posted August 30, 2012 Share Posted August 30, 2012 i think $a is not an array, could you put the code you have who is defined $a Link to comment Share on other sites More sharing options...
nil2567 Posted August 30, 2012 Author Share Posted August 30, 2012 (edited) the code is: global $smarty; $dir = "../modules/folder/upload/images/"; $images = scandir($dir); $ignore = array('.','..'); foreach($images as $image){ if(!in_array($image,$ignore){ $a = $image } } echo $a; // here I have the file $smarty->assign('image',$a.'aaaa'); I'm just having the aaaa tring Edited August 30, 2012 by nil2567 (see edit history) Link to comment Share on other sites More sharing options...
coeos.pro Posted August 30, 2012 Share Posted August 30, 2012 ok i understand... $a is NOT AN ARRAY Link to comment Share on other sites More sharing options...
nil2567 Posted August 30, 2012 Author Share Posted August 30, 2012 at first I simplifyed the code, now I post the real code. it is streng, it looks like a bug to me. 1º I'm reading the files from a directorie 2º I'm doing a foreach to get out of the array 3º I'm trying to output. I can see the variable hava a value but when I pass it to the tpl file the value wont appear Link to comment Share on other sites More sharing options...
coeos.pro Posted August 30, 2012 Share Posted August 30, 2012 foreach($images as $image){ if(!in_array($image,$ignore){ $a = $image } $a is not an array ... foreach($a as $b ){ $c = $b; // if I do an echo here I have string insede $c } $c is empty, normal Link to comment Share on other sites More sharing options...
nil2567 Posted August 30, 2012 Author Share Posted August 30, 2012 ok, try to do this in a module. $a = scandir('folder/'); //than pass it to tpl $smarty->assign('b',$a); it wont pass Link to comment Share on other sites More sharing options...
coeos.pro Posted August 30, 2012 Share Posted August 30, 2012 put {debug} in your tpl file Link to comment Share on other sites More sharing options...
nil2567 Posted August 30, 2012 Author Share Posted August 30, 2012 no value in the {debug} window. It is like a bug to me, because I do echo in the backend of the website and I have a value. in the frontend I don't have Link to comment Share on other sites More sharing options...
nil2567 Posted August 30, 2012 Author Share Posted August 30, 2012 (edited) I think the scope of scandir() don't let it pass to tpl file I don't know why Edited August 30, 2012 by nil2567 (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts