AncientSage Posted July 3, 2006 Share Posted July 3, 2006 [code]Warning: preg_match() expects parameter 2 to be string, array given[/code]Hello, the above is the error I am receiving, this is the function...[code]function audio_files($filelist){ $clean_files = array(); $extensions = array('\.mp3', '\.aiff', '\.wav', '\.mid'); //add audio extensions $read_extensions = '(' . implode('|', $extensions) . ')'; if(preg_match("#$read_extensions$#", $filelist)) { $clean_files[] = $filelist; } return $clean_files;} [/code]Note, $filelist contains ftp_nlist(). Now, I'm guessing this could be a problem with my web host, so I'll go 'head and post that to. [code]cPanel 10.8.1-STABLE_31 (PRO 1.0 (RC2))Apache Core 1.3.34SpamAssasin 3.1phpMyAdmin 2.6.1-rc1PHP 4.4.1 AND 5.0.5PERL 5.8.6MySQL 4.1.13-standard-logProcessor Name: Intel(R) Celeron(TM) CPU 2.40GHzProcessor speed: 2394.027 MHzProcessor cache size: 128 KBOperating System: RedHat Enterprise 3Memory Information: ECC Registered 1024 MB RAM[/code]If anyone could resolve the preg_match() error I am having, please do so...help is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/13580-warning-preg_match-expects/ Share on other sites More sharing options...
effigy Posted July 3, 2006 Share Posted July 3, 2006 [code]Warning: preg_match() expects parameter 2 to be string, array given[/code]That says it all; change your code to loop through the array. Quote Link to comment https://forums.phpfreaks.com/topic/13580-warning-preg_match-expects/#findComment-52607 Share on other sites More sharing options...
AncientSage Posted July 3, 2006 Author Share Posted July 3, 2006 Ah.Well, being slightly new to PHP, would I use a foreach loop to do so? Quote Link to comment https://forums.phpfreaks.com/topic/13580-warning-preg_match-expects/#findComment-52626 Share on other sites More sharing options...
effigy Posted July 3, 2006 Share Posted July 3, 2006 Yes. Assuming $filelist will always be an array:[code]foreach ($filelist as $file) { // Each iteration will have a new file in $file until the array runs out.}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13580-warning-preg_match-expects/#findComment-52634 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.