如何获取数组中的值或如何将数组转换为字符串?

How could I get value in an array or how could I convert array to string?

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

$tIdreturns这个:

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

现在我需要在第二行代码中使用值 2。因为它是数组的形式,所以我收到了一个错误。我怎么能得到只有2的值?

所以如果

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

应该是简单的

echo ( $tId[0]['tId'] ) // should print 2

我不知道你想要什么数据 return 但如果你的数据是一维的,而不是 returning

$query->result_array();

你可以简单地使用

$query->row_array();

这 return 是单个 row/flat 数组,而不是您需要 select 索引或循环遍历的多维数组。就这么简单

echo $tId['tId']

或者,您可以 return 使用

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

然后您可以使用

调用该值
 echo $tId->tId;