prkarpi Posted January 16, 2008 Share Posted January 16, 2008 I have the following code: $GLOBAL_ARRAY_LINK = "<a href=\"" . $GLOBAL_LINK . "Artists$SID&action=sf"; $SubGenreList = array("100"=>"$GLOBAL_ARRAY_LINK&gID=11\">2 Step</a>, $GLOBAL_ARRAY_LINK&gID=12\">Acid</a>, $GLOBAL_ARRAY_LINK&gID=12\">Big Beat</a>, $GLOBAL_ARRAY_LINK&gID=13\">Electro</a>, $GLOBAL_ARRAY_LINK&gID=14\">Funky Breaks</a>, $GLOBAL_ARRAY_LINK&gID=15\">Hardcore Breaks</a>, $GLOBAL_ARRAY_LINK&gID=16\">Nu Skool</a>, $GLOBAL_ARRAY_LINK&gID=17\">Progressive</a>", "116"=>"Acid, Epic, Hard, Progressive, Tech, Tribal"); $split = explode(', ',$SubGenreList[$gID]); foreach ($split as $list) { echo $list . "<br>"; } Moreover, this array will get much bigger with about $gID=50 or so. In other words I will have about 50 items in array. Is there a better solution? Perhaps XML, since I don't want to use DB for it. Quote Link to comment https://forums.phpfreaks.com/topic/86319-solved-is-big-array-a-good-idea/ Share on other sites More sharing options...
tapos Posted January 16, 2008 Share Posted January 16, 2008 Please use code tag. -- Thanks Tapos Pal http://tapos.wordpress.com Quote Link to comment https://forums.phpfreaks.com/topic/86319-solved-is-big-array-a-good-idea/#findComment-441048 Share on other sites More sharing options...
prkarpi Posted January 16, 2008 Author Share Posted January 16, 2008 I have the following code: $GLOBAL_ARRAY_LINK = "<a href=\"" . $GLOBAL_LINK . "Artists$SID&action=sf"; $SubGenreList = array("100"=>"$GLOBAL_ARRAY_LINK&gID=11\">2 Step</a>, $GLOBAL_ARRAY_LINK&gID=12\">Acid</a>, $GLOBAL_ARRAY_LINK&gID=12\">Big Beat</a>, $GLOBAL_ARRAY_LINK&gID=13\">Electro</a>, $GLOBAL_ARRAY_LINK&gID=14\">Funky Breaks</a>, $GLOBAL_ARRAY_LINK&gID=15\">Hardcore Breaks</a>, $GLOBAL_ARRAY_LINK&gID=16\">Nu Skool</a>, $GLOBAL_ARRAY_LINK&gID=17\">Progressive</a>", "116"=>"Acid, Epic, Hard, Progressive, Tech, Tribal"); $split = explode(', ',$SubGenreList[$gID]); foreach ($split as $list) { echo $list . "<br>"; } Moreover, this array will get much bigger with about $gID=50 or so. In other words I will have about 50 items in array. Is there a better solution? Perhaps XML, since I don't want to use DB for it. Quote Link to comment https://forums.phpfreaks.com/topic/86319-solved-is-big-array-a-good-idea/#findComment-441054 Share on other sites More sharing options...
trq Posted January 16, 2008 Share Posted January 16, 2008 I would not consider an array containing 50 indexes large at all. Quote Link to comment https://forums.phpfreaks.com/topic/86319-solved-is-big-array-a-good-idea/#findComment-441055 Share on other sites More sharing options...
prkarpi Posted January 16, 2008 Author Share Posted January 16, 2008 I would not consider an array containing 50 indexes large at all. Is code above a good idea to have or is there other better solutions. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/86319-solved-is-big-array-a-good-idea/#findComment-441066 Share on other sites More sharing options...
trq Posted January 16, 2008 Share Posted January 16, 2008 You could neaten the code up quite a bit, and using caps for variable names is poor style IMO. Constants (and globals) are normally defined using caps. But yeah, this code could be much simpler and your site more dynamic in nature if you used a database instead of hard coding this into your app. Quote Link to comment https://forums.phpfreaks.com/topic/86319-solved-is-big-array-a-good-idea/#findComment-441092 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.