0

How do I get only email from this array in same method to pass as variable for the model?

$user_data['userinfo'] = $this->logindatamodel->login_data();
$tsp = $this->AttendanceModel->get_batch_byUser();
echo '<pre>';
print_r($user_data);

Output:

Array
(
    [userinfo] => stdClass Object
        (
            [ID] => 3
            [Name] => Md. Aminur Rahman
            [Email] => [email protected]
            [Password] => 202cb962ac59075b964b07152d234b70
            [Role] => 4
        )

)

1 Answer 1

1

Just do,

 echo $user_data['userinfo']->Email

you will get the email printed and this is the solution for only single dimensional array.If it is multidimensional

you will put it on a loop and

echo $user_data['userinfo'][0]->Email;

or

  for($i=0;$i<count($user_data['userinfo'];$i++)
{
   echo $user_data['userinfo'][$i]->Email;
}
Sign up to request clarification or add additional context in comments.

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.