convert a string into an array

From: Date: Fri, 02 Apr 2010 23:05:15 +0000
Subject: convert a string into an array
Groups: php.general 
Request: Send a blank email to php-general+get-303755@lists.php.net to get a copy of this message
Hello everyone, It's quite simple but I'm still stuck. What I need is the following: I have an array as a parameter of my custom function. However, I'd like to allow users to enter a string instead of an array. In this case (if the parameter is a string), it must be replaced with an array containing only one item - actually, that string. What I'm doing gives me (presumably) errors; function Send ($tonames, $toemails, $subject, $message) { ... if ((!is_array($tonames)) || (!is_array($toemails))) { $tonames[]=$tonames; $toemails[]=$toemails; } I can't give the new array a new name since I address it further in a loop as my function's parameter... hope you understand what I'm saying) Thanks! -- With best regards from Ukraine, Andre Http://oire.org/ - The Fantasy blogs of Oire Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ jabber.org Yahoo! messenger: andre.polykanine; ICQ: 191749952 Twitter: http://twitter.com/m_elensule

« previous php.general (#303755) next »