Jump to content

Archived

This topic is now archived and is closed to further replies.

AncientSage

Warning: preg_match() expects...

Recommended Posts

[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.34
SpamAssasin 3.1
phpMyAdmin 2.6.1-rc1
PHP 4.4.1 AND 5.0.5
PERL 5.8.6
MySQL 4.1.13-standard-log

Processor Name: Intel(R) Celeron(TM) CPU 2.40GHz
Processor speed: 2394.027 MHz
Processor cache size: 128 KB
Operating System: RedHat Enterprise 3
Memory Information: ECC Registered 1024 MB RAM
[/code]

If anyone could resolve the preg_match() error I am having, please do so...help is appreciated.

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.