0

I have to make a directory and save the file, but there is an error that written in title. Help me to solve this error. My code is below.

  function main() {
      $scrapper = new Cloaked_Scraper();
      // Prefix of URL's
      $url_prefix = "link";
      // URL
      $urls = array("www.something.com?");
      // Get ID from every URL and will save on index one of $url array
      $urls[1] = ((explode("www.something.com?id=com.", $urls[0])));
      $urls[0] = $url_prefix;
      $urls[0];
      $urls[1];


      //mkdir("../temp/", 0777 /* The mode is 0777 by default, which means the widest possible access */);

      // Destination folder where this file will save, and file name.
      $output_dir[0] = "../temp/".$urls[0].$urls[1].".html";
      $results = $scrapper->fetch($urls, $output_dir);
      var_dump($results);

    }

    main();
1
  • Full Error Message please (with linenumber) Commented Dec 7, 2013 at 13:03

2 Answers 2

1

I don't know what Cloaked_Scraper is, but it seems that its fetch method only accepts a string as its first or second parameter. You pass an array to both of them.

I think $output_dir needs to be a normal string, but by assigning to $output_dir[0] you implicitly make it an array.

Change that line to this and see what happens:

$output_dir = "../temp/".$urls[0].$urls[1].".html";

But in general, I think your code is very confusing. It seems like you are recycling items of the $urls array while you should actually use separate variables.

Sign up to request clarification or add additional context in comments.

Comments

0
$urls[1] = ((explode("www.something.com?id=com.", $urls[0])));

explodes a String to an Array of strings, in detail, $urls[1] contains: array( '', 'id=com');

You now try to insert this Array as a this Line:

$output_dir[0] = "../temp/".$urls[0].$urls[1].".html";

Just use the correct index for the String:

$output_dir[0] = "../temp/".$urls[0].$urls[1][0].".html";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.