[PHP-DB] I want to remove the last comma

2008-08-12 Thread A. Joseph
This the script $dir = images; $d = opendir($dir); $out = var tinyMCEImageList = new Array(\n; while(false != ($entry = readdir($d))) { if(preg_match(/(.jpg|.gif|.png)$/, $entry) != false) { $out .= ['{$entry}', '{$dir}/{$entry}'],\n; } } $out .= );\n; This the out put var

Re: [PHP-DB] I want to remove the last comma

2008-08-12 Thread Micah Gersten
Create an Array in the loop and then join with ,\n. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com A. Joseph wrote: This the script $dir = images; $d = opendir($dir); $out = var tinyMCEImageList = new Array(\n; while(false != ($entry = readdir($d)))

Re: [PHP-DB] I want to remove the last comma

2008-08-12 Thread YVES SUCAET
Subject: Re: [PHP-DB] I want to remove the last comma Create an Array in the loop and then join with ,\n. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com A. Joseph wrote: This the script $dir = images; $d = opendir($dir); $out = var tinyMCEImageList = new

Re: [PHP-DB] I want to remove the last comma

2008-08-12 Thread YVES SUCAET
: A. Joseph [EMAIL PROTECTED] To: YVES SUCAET [EMAIL PROTECTED] Subject: Re: [PHP-DB] I want to remove the last comma I tried all this, all i want is something line this var tinyMCEImageList = new Array( ['1_h_1.gif', 'images/1_h_1.gif'], ['1_h_1.gif', 'images/1_h_1.gif'] ); But this what i got var

Re: [PHP-DB] I want to remove the last comma

2008-08-12 Thread Dee Ayy
What I would do is change var tinyMCEImageList = new Array(\n; to have a space and then the newline character at the end like so var tinyMCEImageList = new Array( \n; then change your last $out line $out .= );\n; to strip the last 2 characters (which always gets called) and closes the Array

Re: [PHP-DB] I want to remove the last comma

2008-08-12 Thread Evert Lammerts
JSON does the trick for you (www.json.org), and PHP's glob() gets rid of your readdir() overhead (you'll need PHP 5.2 or later for this): $path = /path/to/images/; $images = glob($path . {*.jpg,*.gif,*.png}, GLOB_BRACE); for ($i = 0; $i sizeof($images); $i++) $images[$i] = array($images[$i],

Re: [PHP-DB] I want to remove the last comma

2008-08-12 Thread Yi Wang
On Wed, Aug 13, 2008 at 3:27 AM, A. Joseph [EMAIL PROTECTED] wrote: This the script $dir = images; $d = opendir($dir); $out = var tinyMCEImageList = new Array(\n; while(false != ($entry = readdir($d))) { if(preg_match(/(.jpg|.gif|.png)$/, $entry) != false) { $out .= ['{$entry}',