TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Need to convert string to array (http://www.talkphp.com/general/3382-need-convert-string-array.html)

CLCook 09-27-2008 02:35 PM

Need to convert string to array
 
Hi guys,

This seems really simple to me, but I've had no luck. I need help! :)

I've got file upload script which is working just fine. Here's the code I'm using to define the file extensions which are uploadable.

PHP Code:

$uploadtypes = array( "png""gif""jpeg""jpe""jpg""fla""html""doc"); 

So, here's my problem. I want this editable in the GUI. So, I added a field in my MySQL database and had $uploadtypes equal the field.

I've tried several functions to separate the values and to explode into an array. No luck.

I want the end-use to type "png, gif, jpeg, fla" etc into a string. Then, I need that coverted into the PHP line above.

Any suggestions?

Enfernikus 09-27-2008 05:03 PM

Don't know if I'm getting you very well but you could use the

serialize
unserialize


functions

Kalle 09-27-2008 05:16 PM

Something like:

PHP Code:

$types = Array('tiff');
$str 'png,gif,jpg';

$types array_merge(implode(','$str), $types); 



All times are GMT. The time now is 09:32 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0