0
$tId = $this->its_model->get_status_type($property_id);
print_r($tId);
$tsId = $this->its_model->get_sub_status_type($tId);

The $tId returns this:

Array ( [0] => Array ( [tId] => 2 ) )

And now I need to use the value 2 in the second line of code. As it is in the form of array I am getting an error. How could I get the value only that is 2?

2 Answers 2

2

So if

$tId is
Array ( [0] => Array ( [tId] => 2 ) )

it should be simply

echo ( $tId[0]['tId'] ) // should print 2
Sign up to request clarification or add additional context in comments.

Comments

0

I don't know what Data you are trying to return but if your data is one dimensional, instead of returning

$query->result_array();

you can simply use

$query->row_array();

This returns a single row/flat array rather than a multidimensional array that you need to select the index or loop through. It will be as easy as

echo $tId['tId']

Alternatively you can return an object by using

 $query->row() or $query->result();

You can then call the value by using

 echo $tId->tId;

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.