0

my code in PHP :

    $stuff = array($this->complaint_model->get_reply($id)->result());

    print_r($stuff);

result :

Array (
    [0] => Array (
        [0] => stdClass Object (
            [id_customer] => 21 
            [id_complaint] => 2 
            [id] => 4 
            [nama_customer] => Muhammad Bima Zehansyah 
            [from] => Admin 
            [balasan] => coba update 
         ) 
     ) 
)

my question is , how to get value [nama_customer] ? thx before guys

0

3 Answers 3

1

Try this

$stuff = array($this->complaint_model->get_reply($id)->result());
echo $stuffVal = $stuff[0][0]->nama_customer;
Sign up to request clarification or add additional context in comments.

2 Comments

$stuffVal is absolutely not necessary
well played bro!
0

Get the value like this

$stuff[0][0]->nama_customer

Here you have multidimensional array object that's why you need to first Travers two array like $stuff[0][0] and then the object like $stuff[0][0]->nama_customer

2 Comments

thx bro for share !!
you are welcome and close your question by accepting my answer :)
0

Actually you do not need to put the result into additional array and it would be wise to check if the result is not empty. So you just take a first item from your result (which is an object) and call the parameter nama_customer

$stuff = $this->complaint_model->get_reply($id)->result();
if (!empty($stuff[0]))
    echo $stuff[0]->nama_customer;

1 Comment

nice answer bro!! good job

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.