2
array(1) {
  [0] => array(2) {
    ["list_length"] => string(2) "10" 
    ["id"] => array(4) {
      [0] => string(1) "1"
      [1]=> string(2) "10" 
      [2]=> string(1) "3"
      [3]=> string(2) "13"
    }
  }
}

codeigniter

How can I get the values 1,10,3,13 inside

["id"]=> array(4) {
  [0]=> string(1) "1"
  [1]=> string(2) "10"
  [2]=> string(1) "3"
  [3]=> string(2) "13"
}

I tried :

public function recieve($data){
    //var_dump($data);
    $ids = $data;
    var_dump($ids);
    $this->db->set('recieve', '1');
    $this->db->where('no', $ids);
    $this->db->update('trainee')`
 }
5
  • man, this question is as bad as it gets Commented May 24, 2018 at 7:21
  • why you are using <recieve> method , its not clear, pls specify Commented May 24, 2018 at 7:29
  • What have you tried so far? The given array has clear keys, so why not use them? Commented May 24, 2018 at 7:30
  • 2
    pls always response to the answers by giving some comments or ,if it helps you, by marking it as green and upvoting, it is the best way to thanks all the programmers Commented May 24, 2018 at 9:36
  • how to upvoting just my first time here sorry . i already check the answer that helped my problem Commented May 24, 2018 at 23:50

1 Answer 1

1

Hope this will help you :

Working demo : https://eval.in/1009067

$arr = array(array("list_length" => "10" ,"id" => array("1", "10" , "3" , "13")));
if (! empty($arr[0]['id']))
{
   $data = $arr[0]['id'];
}
print_r($data);

Output :

Array
(
    [0] => 1
    [1] => 10
    [2] => 3
    [3] => 13
)

In your recieve method use like this :

$arr = array(array("list_length" => "10" ,"id" => array("1", "10" , "3" , "13")));

if (! empty($arr[0]['id']))
{
   $data = $arr[0]['id'];
}

/*pass this $data to your method like this :*/

public function recieve($data)
{
    /*if $data is return the array just like above in question 
      get all ids like this 
      $ids = $data[0]['id'];
    */
    $ids = $data;
    //var_dump($ids);
    $this->db->set('recieve', '1');
    $this->db->where_in('no', $ids);
    $this->db->update('trainee')`
 }
Sign up to request clarification or add additional context in comments.

6 Comments

why are you using <recieve> method , its not clear, pls specify
recieve is my function where i want to change the status. default value is 0 means not yet recieve then when recieve change to 1
i cant get the datas "1"10"3" "13"
see my updated answer for that, pass all the ids like this
in query use where_in instead of where as in my anwer
|

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.