[英]Joomla 3.0 JFactory::getApplication() get always returns null
I'm trying the extract the array data from a nested array (shown is part of a var_dump): 我正在尝试从嵌套数组中提取数组数据(显示为var_dump的一部分):
["passcodes"]=> array(2) {
[0]=> array(1) {
[0]=> string(33) "pAWn78hI2Uw5FA9iSGVuAkvISM0LTWL9X"
}
[1]=> array(1) {
[0]=> string(33) "dfS7VHqEXmcSkBubESaA0mIt8rEy2fSWE"
}
}
With the following PHP: 使用以下PHP:
<?php
$app = JFactory::getApplication();
$input = $app->input;
$codes= $input->get('passcodes',array(),'array');
echo "*********** ".$codes." **********";
print_r($codes);
var_dump($codes);
var_dump($input);
?>
^^ I can't seem how to figure out the declaration for $codes, it's always null and size 0 ^^我似乎无法弄清楚$ codes的声明,它始终为null,大小为0
Instead of $input->get('passcodes',array(),'array')
try: 代替
$input->get('passcodes',array(),'array')
尝试:
$vars = 'passcodes'; // Associative array of keys and filter types to apply
$source = 'youArrayName'; // Array to retrieve data from
$codes = $input->getArray(array $vars, $source);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.