LiamProductions Posted July 7, 2007 Share Posted July 7, 2007 Hey. I can't find the problem on this: <?php $fruits = array ('red' => 'apple', 'orange' => 'orange', 'yellow' => 'banana'); foreach ($fruits as $fruit_key => $fruit_value) { echo sorta($fruit_key.' - '.$fruit_value. '<br />')); } ?> but it is giving me a error. Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 7, 2007 Share Posted July 7, 2007 A few suggestions. If you want people to read your threads, provide a more descriptive title than 'problem'. If you 'it is giving me a error', tell us exactly what it is and where it occurs. And, of course, you've already checked the manual. Right? Quote Link to comment Share on other sites More sharing options...
LiamProductions Posted July 7, 2007 Author Share Posted July 7, 2007 Oh ok... And heres the error message: Parse error: syntax error, unexpected T_FOREACH in /home/liam/public_html/phpvideotutorial.php on line 7 Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 7, 2007 Share Posted July 7, 2007 echo sorta($fruit_key.' - '.$fruit_value. '<br />')); too many ) there, perhaps? Quote Link to comment Share on other sites More sharing options...
LiamProductions Posted July 7, 2007 Author Share Posted July 7, 2007 I took away 1 ) and i got this: Fatal error: Call to undefined function: sorta() in /home/liam/public_html/phpvideotutorial.php on line 9 Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 7, 2007 Share Posted July 7, 2007 OK. The error message is pretty explicit. The function named sorta() is not defined. Unless you defined it yourself elsewhere in some code, you can only use functions that are supported by your installed version of php. As always, the manual is very useful - http://ca.php.net/manual/en/function.sort.php Quote Link to comment Share on other sites More sharing options...
LiamProductions Posted July 7, 2007 Author Share Posted July 7, 2007 in PHP.net Manual... sorta is suppose to sort the arrays alphebetically Quote Link to comment Share on other sites More sharing options...
per1os Posted July 7, 2007 Share Posted July 7, 2007 I think your mistaken. http://us2.php.net/manual/en/function.sort.php asort is for sorting but mainting index association. Sort automaticalyl goes by the natrual sort meaning it will sort numbers before letters etc. sorta is not a function. Quote Link to comment 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.