jani Posted May 20, 2008 Share Posted May 20, 2008 Hello all, i am new here ..i was thinking of a function i could use, but i don't really know where to start... I have "shortnames" for items listed in a database, and i am seeking a way to connect a "shortname" to a "fullname". I would not like to have the equivalent for the shortname in the database, but just have a function in php where i can feed "shortname" and it will then return me the "fullname". Example: if ($shortname="STREET1") { $fullname="The Very Long Name of the Street1"; } if ($shortname="STREET2") { $fullname="The Even Longer Name of the Street2"; } ... this is how i can get it working, but isn't there a simplier way to do this? One solution is of course to make a function, that has all the IF-statements(20-25), and then i just throw in the shortname and it will return the fullname. Is it possible to use strings or something like this; STREET1:"The Very Long Name of the Street1" STREET2:"The Even Longer Name of the Street2" And then build a function of it ? All shortnames and fullnames occure only once, i.e. no streets with the same short/fullname. Example code appreciated. TIA /Jani Link to comment https://forums.phpfreaks.com/topic/106462-convert-shortname-to-fullname/ Share on other sites More sharing options...
revraz Posted May 20, 2008 Share Posted May 20, 2008 Why don't you want it in the DB, it makes more sense. Link to comment https://forums.phpfreaks.com/topic/106462-convert-shortname-to-fullname/#findComment-545692 Share on other sites More sharing options...
jani Posted May 20, 2008 Author Share Posted May 20, 2008 If it can be made in a simple way in php, i'd prefer that solution since otherwise i would have to make quite some DB lookups and the code would get way too nestled... Altough, i need to reconsider that thought too, thanks for your input. /Jani Link to comment https://forums.phpfreaks.com/topic/106462-convert-shortname-to-fullname/#findComment-545697 Share on other sites More sharing options...
revraz Posted May 20, 2008 Share Posted May 20, 2008 If you hard code it, it sounds like a hassle to update any changes. Plus, you are making your code a lot longer than it should be. Link to comment https://forums.phpfreaks.com/topic/106462-convert-shortname-to-fullname/#findComment-545710 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.