0

My controller is:

public function store()
{
    $links = array();
    $html = new \Htmldom('http://randomsite.org');

    foreach($html->find('a') as $a) 
    {
        $links[] = $a->href;
    }

}

and i have the database table called result with field:

id
name
url (i want to put the array here)
desc

what I want is multiple records as number links

1

1 Answer 1

2

If I am right. You need the solution to store data into database.

foreach($links as $link)
{
  $result= new Result;        //here Result is the model name for the table result
  $result->id =  $link[0];  //id
  $event->name = $link[1];  //name
  $event->url =  $link[2];  //url
  $event->desc = $link[3];  //desc
  $event->save();
}

Here you loop through each array of items and insert multiple rows in the table

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

1 Comment

Thank you man, you save me! i do a foreach and $result->url and stop, thank you again!

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.