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. Link to comment https://forums.phpfreaks.com/topic/58859-problem/ 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? Link to comment https://forums.phpfreaks.com/topic/58859-problem/#findComment-292071 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 Link to comment https://forums.phpfreaks.com/topic/58859-problem/#findComment-292072 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? Link to comment https://forums.phpfreaks.com/topic/58859-problem/#findComment-292080 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 Link to comment https://forums.phpfreaks.com/topic/58859-problem/#findComment-292082 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 Link to comment https://forums.phpfreaks.com/topic/58859-problem/#findComment-292086 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 Link to comment https://forums.phpfreaks.com/topic/58859-problem/#findComment-292094 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. Link to comment https://forums.phpfreaks.com/topic/58859-problem/#findComment-292112 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.