Welcome Guest, Not a member yet? Register   Sign In
passing an array retrieved from model function1 to model function2
#1

[eluser]amipaxs[/eluser]
Hello friends,

I'll briefly try to explain what I need using an example,

Controller

Code:
$data['retrieved_elements'] = $this->MWorkOrder->select_all_rows_active($this->input->post('id_WO'));

  $this->MWOrkOrder->process2($data)

Is that right?, i need to pass all the retrieved array to a second function in the model , but how do I extract the array inside an array.?


thanks
#2

[eluser]Sanjay Sarvaiya[/eluser]
you have done right.

using foreach loop you can explode array on second function.
#3

[eluser]Sanjay Sarvaiya[/eluser]
you have done right.

using foreach loop you can explode array on second function.
#4

[eluser]amipaxs[/eluser]
ok,

When I pass the retrieved array $this->MWOrkOrder->process2($data) to my second function in the model ,i get an array inside an array inside an array(as seen on the image), i need to get the id_elem value
#5

[eluser]amipaxs[/eluser]
ok,

When I pass the retrieved array $this->MWOrkOrder->process2($data) to my second function in the model ,i get an array inside an array inside an array(as seen on the image), i need to get the id_elem value


Code:
Array
     (
         [elements] => Array
            (
                [0] = Array
                   (
                     [id_elem] = 1
                   )
                 [1] = Array
                   (
                     [id_elem] = 2
                   )
           .....
#6

[eluser]CroNiX[/eluser]
So iterate over the array and access them.

Code:
foreach($data['elements'] as $element)
{
  echo $element['id_elem'] . '<br />';
}

or get all of the IDs into a single array or however you need it

Code:
$ids = array();
foreach($data['elements'] as $element)
{
  $ids[] = $element['id_elem'];
}
print_r($ids);

//outputs
Array (
[0] => 1,
[1] => 2
)




Theme © iAndrew 2016 - Forum software by © MyBB