Re: Warning: file_get_contents(): Filename cannot be empty

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hadi wrote:

> $string2 = $item->description;
> preg_match('/http.*.jpg/',$string2,$match2);
> $convert = implode(",", $match2);

That is rather misleading code.  After calling preg_match(), $match2
always is an array with a single element (if $string2 matches) or an
empty array (if $string2 doesn't match).  Calling implode(',', $match2)
doesn't really make sense.  I suggest using an if statement instead; see
example #1[1] on the manual page.

A minor issue is the unescaped dot in the regexp.  Use '/http.*\.jpg/'
instead.

[1] <http://php.net/manual/en/function.preg-match.php#example-4947>

-- 
Christoph M. Becker

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux