Re: Warning: file_get_contents(): Filename cannot be empty
| From: | Christoph Becker | Date: | Mon, 09 Mar 2015 13:16:38 +0000 |
| Subject: | Re: Warning: file_get_contents(): Filename cannot be empty | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324611@lists.php.net to get a copy of this message | ||
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