Php 我正在使用CodeIgniter,并试图根据查询返回设置一个变量
我可以使用打印并返回此数据:Php 我正在使用CodeIgniter,并试图根据查询返回设置一个变量,php,codeigniter,Php,Codeigniter,我可以使用打印并返回此数据: Array ( [array] => Array ( [status] => false [message] => The %s subscription code is out of date. ) ) 我需要能够将元素“状态”和“消息”设置为变量。(在本例中status=false)如果我理解正确,是否希望$status和$message保存相应的值 $input = array(
Array (
[array] => Array (
[status] => false
[message] => The %s subscription code is out of date.
)
)
我需要能够将元素“状态”和“消息”设置为变量。(在本例中status=false)如果我理解正确,是否希望
$status
和$message
保存相应的值
$input = array(
'status' => false,
'message' => 'The %s subscription code is out of date.'
);
$output = array();
foreach ($input as $key => $value) {
$$key = $value; // assign $value using variable variable
}
print($status); // prints nothing because it's false
print($message); // The %s subscription code is out of date.
如果我理解正确,是否希望
$status
和$message
保存相应的值
$input = array(
'status' => false,
'message' => 'The %s subscription code is out of date.'
);
$output = array();
foreach ($input as $key => $value) {
$$key = $value; // assign $value using variable variable
}
print($status); // prints nothing because it's false
print($message); // The %s subscription code is out of date.
$data=array(
“状态”=>“错误”,
'消息'=>'%s订阅代码已过期。'
);
提取(数据);
echo$status;//输出“false”,因为如果您的状态为字符串。
回声“
”;
echo$message;//输出%s订阅代码已过期。
是一个非常流行的函数,它将数组中的元素转换为其自身格式的变量(
“状态”=>“错误”,
'消息'=>'%s订阅代码已过期。'
);
提取(数据);
echo$status;//输出“false”,因为如果您的状态为字符串。
回声“”; echo$message;//输出%s订阅代码已过期。
是一个非常流行的函数,它可以将数组中的元素按其自身的格式转换为变量。请提供使您走到这一步的代码。请提供使您走到这一步的代码。整洁!我不知道
extract()
-我更喜欢你的方法。整洁!我不知道extract()
-我更喜欢你的方法。