robert_gsfame Posted September 21, 2009 Share Posted September 21, 2009 $findname=$array['name']; $split = explode(' ',$findname); foreach($split as $index=>$value) $value = ucwords(strtolower($value)); $findname1=implode(' ',$value); When i echo the $findname; it returns -----------> implode() [function.implode]: Bad arguments. in Which part is wrong?? Quote Link to comment https://forums.phpfreaks.com/topic/174972-implode-explode/ Share on other sites More sharing options...
RichardRotterdam Posted September 21, 2009 Share Posted September 21, 2009 It's because $value is not an array Quote Link to comment https://forums.phpfreaks.com/topic/174972-implode-explode/#findComment-922165 Share on other sites More sharing options...
robert_gsfame Posted September 21, 2009 Author Share Posted September 21, 2009 so how it should be? Quote Link to comment https://forums.phpfreaks.com/topic/174972-implode-explode/#findComment-922166 Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 What is this? $array['name'] IE: what is it's value? Where did it come from? More code needed Quote Link to comment https://forums.phpfreaks.com/topic/174972-implode-explode/#findComment-922168 Share on other sites More sharing options...
robert_gsfame Posted September 21, 2009 Author Share Posted September 21, 2009 i retrieve the value from database $array = mysql_fetch_array('$sqlquery'); Quote Link to comment https://forums.phpfreaks.com/topic/174972-implode-explode/#findComment-922170 Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 Can you provide the actual code please Quote Link to comment https://forums.phpfreaks.com/topic/174972-implode-explode/#findComment-922172 Share on other sites More sharing options...
robert_gsfame Posted September 21, 2009 Author Share Posted September 21, 2009 i think the problem is with this part implode(' ',$value) as i've tried removing implode part and changing it with echo $value."<br>"; It returns the value in array Quote Link to comment https://forums.phpfreaks.com/topic/174972-implode-explode/#findComment-922173 Share on other sites More sharing options...
RichardRotterdam Posted September 21, 2009 Share Posted September 21, 2009 If it's from a db why do you cram the values in of an array into a string so you can explode it into an array again? Maybe you should try something like this instead <?php while($row = mysql_fetch_array( $result )) { echo ucwords(strtolower($row['name'])); } Quote Link to comment https://forums.phpfreaks.com/topic/174972-implode-explode/#findComment-922178 Share on other sites More sharing options...
knsito Posted September 21, 2009 Share Posted September 21, 2009 Your code edited $findname=$array['name']; $split = explode(' ',$findname); foreach($split as $index=>$value) $value_new[] = ucwords(strtolower($value)); $findname1=implode(' ',$value_new); But why not just $findname1 = ucwords(strtolower($array['name'])); Since the words are already seperated by space, ucwords will capitalize each of them for you edit: err yeah what DJ Kat said $findname=$array['name']; $split = explode(' ',$findname); foreach($split as $index=>$value) $value = ucwords(strtolower($value)); $findname1=implode(' ',$value); When i echo the $findname; it returns -----------> implode() [function.implode]: Bad arguments. in Which part is wrong?? Quote Link to comment https://forums.phpfreaks.com/topic/174972-implode-explode/#findComment-922354 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.