182x Posted August 8, 2007 Share Posted August 8, 2007 Hey guys, Just wondering what the differences between mysql_fetch_assoc() and mysql_fetch_array() and when should one be used over the other? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/63826-solved-function-question/ Share on other sites More sharing options...
cooldude832 Posted August 8, 2007 Share Posted August 8, 2007 assoc gives you associtive only gives, array gives you index/associtve, otherwise none interms of speed the difference is minimal unless you have a query greater than 100 cols by 100 results or a lot of large fields. Quote Link to comment https://forums.phpfreaks.com/topic/63826-solved-function-question/#findComment-318098 Share on other sites More sharing options...
182x Posted August 8, 2007 Author Share Posted August 8, 2007 Thanks sorry for the newbie quesion but how does an assoc differ from an index/assoc array? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/63826-solved-function-question/#findComment-318107 Share on other sites More sharing options...
cooldude832 Posted August 8, 2007 Share Posted August 8, 2007 arrays are formed off 2 styles of keys associtive i.e ($myarray['fish'] or $myarray['cat']) and indeixal i.e ($myarray[0] = "fish" or $myarray[1] = "cat") both have advantages. Associtive can be used off a user supplied variable or mysql returned string to access them i.e if you had pets and someone said in the search for cat and you could say $myarray[$_GET['pet']] to return what you need. But indexial arrays let you do quick loops through them using while, foreach loops. Its something you can pick up on as you get better at php. Tehre are also what i call hybrid arrays made up of associtve keys with an indexing part ie $pets['animal_1'] you can recall it using a combo string like $pet['animal'.$i] gives you even more options Quote Link to comment https://forums.phpfreaks.com/topic/63826-solved-function-question/#findComment-318115 Share on other sites More sharing options...
182x Posted August 8, 2007 Author Share Posted August 8, 2007 That was great. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/63826-solved-function-question/#findComment-318157 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.