proud Posted January 15, 2009 Share Posted January 15, 2009 If I have the names john richard and jack.. I want them to be written in the formula "john","richard","jack" .. what is the easiest solution to use because I have got hundreds of names on which I want to apply on them the formula I mentioned above and the only thing that separates them is spaces e.g. (john richard jack mark etc..) Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted January 15, 2009 Share Posted January 15, 2009 $names = "john richard jack mark"; $nameArray = str_word_count($names,2); $nameList = implode('","',$nameArray); if ($nameList > '') { $nameList = '"'.$nameList.'"'; } Quote Link to comment Share on other sites More sharing options...
RussellReal Posted January 15, 2009 Share Posted January 15, 2009 even though this is solved, I thought I might add something which could be of use to you later on.. <?php function addQuotes(&$val) { $val = "\"".addslashes($val)."\""; } $array = array("mark","jack","jimmy","susan"); array_walk($array,"addQuotes"); echo implode(",",$array); ?> 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.