clankill3r Posted December 9, 2011 Share Posted December 9, 2011 atm i have this in a function: $returnInfo = array(); $returnInfo["totalWords"] = $totalWords; $returnInfo["uniqueWords"] = count($uniqueWords); $returnInfo["positiveWords"] = $positiveWords; $returnInfo["negativeWords"] = $negativeWords; $returnInfo["rating"] = $mappedrating; return $returnInfo; If i recursive print it it says Array instand of my expected values. p.s., i have found examples where the array get's created in 1 line with all there values but i prefer not to do that since it will be a very long line. Quote Link to comment https://forums.phpfreaks.com/topic/252855-fill-aray-with-keys-and-values/ Share on other sites More sharing options...
kicken Posted December 9, 2011 Share Posted December 9, 2011 If i recursive print it it says Array instand of my expected values. p.s., i have found examples where the array get's created in 1 line with all there values but i prefer not to do that since it will be a very long line. When you say recursive print, what do you mean? using print_r or var_dump? As for the one line thing, I assume your talking about setting the keys/values inside the array() construct. It doesn't have to be on one line: $returnInfo = array( 'totalWords' => $totalWords, 'uniqueWords' => count($uniqueWords), 'positiveWords' => $positiveWords, 'negativeWords' => $negativeWords, 'rating' => $mappedrating ); return $returnInfo; Doesn't really matter one way or the other though, just a matter of preference. Quote Link to comment https://forums.phpfreaks.com/topic/252855-fill-aray-with-keys-and-values/#findComment-1296372 Share on other sites More sharing options...
Drongo_III Posted December 9, 2011 Share Posted December 9, 2011 Are you just trying to print the entire array? You can't print or echo an array - only individual array values. To get the whole array use print_r($Name_of_Array); atm i have this in a function: $returnInfo = array(); $returnInfo["totalWords"] = $totalWords; $returnInfo["uniqueWords"] = count($uniqueWords); $returnInfo["positiveWords"] = $positiveWords; $returnInfo["negativeWords"] = $negativeWords; $returnInfo["rating"] = $mappedrating; return $returnInfo; If i recursive print it it says Array instand of my expected values. p.s., i have found examples where the array get's created in 1 line with all there values but i prefer not to do that since it will be a very long line. Quote Link to comment https://forums.phpfreaks.com/topic/252855-fill-aray-with-keys-and-values/#findComment-1296376 Share on other sites More sharing options...
clankill3r Posted December 9, 2011 Author Share Posted December 9, 2011 i mean print_r thanks, it works like a champ now! Quote Link to comment https://forums.phpfreaks.com/topic/252855-fill-aray-with-keys-and-values/#findComment-1296383 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.