smith.james0 Posted May 24, 2006 Share Posted May 24, 2006 I am trying to us list() in the code below, the only problem with it is it only returns the first three varables, is there a limit on the list() function? I carn't find anything on php.net [img src=\"style_emoticons/[#EMO_DIR#]/excl.gif\" style=\"vertical-align:middle\" emoid=\":excl:\" border=\"0\" alt=\"excl.gif\" /] [code]<?php $absolute_path = pathinfo($_SERVER['SCRIPT_FILENAME']);echo 'Path to this file: '.$absolute_path['dirname'].""; list($home,$account,$public,$visitors) = explode('/', $absolute_path['dirname']);echo "$home <br> $account <br> $public <br> $visitors <br>";if ( $visitors=='visitors' ) {echo"yes";}else{echo "no";}?>[/code]The idea of the code is to echo yes when it's in the visitors dir else echo no. I never get a value for $visitors even when it's in that dir/home/*******/public_html/visitors Can anyone help?Thanks James Link to comment https://forums.phpfreaks.com/topic/10383-does-list-have-a-limit/ Share on other sites More sharing options...
448191 Posted May 24, 2006 Share Posted May 24, 2006 Your problem lies elsewhere, I tested it, and it works fine with my dirstructure.If you're really stuck, we need more info. Link to comment https://forums.phpfreaks.com/topic/10383-does-list-have-a-limit/#findComment-38694 Share on other sites More sharing options...
smith.james0 Posted May 24, 2006 Author Share Posted May 24, 2006 Please take no notice of most of the contect of the page. apaert from the bottom bit. It's one of my script test pages, both files are the same, with the code above. Link to comment https://forums.phpfreaks.com/topic/10383-does-list-have-a-limit/#findComment-38702 Share on other sites More sharing options...
448191 Posted May 25, 2006 Share Posted May 25, 2006 I'ts because you use '/' to explode the dirname. The first '/' represents 'root', so use this:[code]list($root,$home,$account,$public,$visitors) = explode('/', $absolute_path['dirname']);[/code]$root will be empty.You could also trim-off the first slash:[code]list($home,$account,$public,$visitors) = explode('/', substr($absolute_path['dirname'],1,strlen($absolute_path['dirname'])));[/code]But I recommend the first method. Link to comment https://forums.phpfreaks.com/topic/10383-does-list-have-a-limit/#findComment-38799 Share on other sites More sharing options...
smith.james0 Posted May 25, 2006 Author Share Posted May 25, 2006 Thanks for that! works great.ThankyouJames Link to comment https://forums.phpfreaks.com/topic/10383-does-list-have-a-limit/#findComment-38972 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.