Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/86319-solved-is-big-array-a-good-idea/
Share on other sites

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.