Php 如何在codeigniter视图中获得此阵列结果和回音
foreach此数组结果并回显结果Php 如何在codeigniter视图中获得此阵列结果和回音,php,mysql,codeigniter,Php,Mysql,Codeigniter,foreach此数组结果并回显结果 foreach($array作为$value){ foreach($行的值){ if(is_数组($row)){ foreach($key=>$val的行){ 回显$key.“=>”$val.“”; }///endForeach }///恩迪夫 否则{ echo$行; }////恩德斯 } } 根据您尝试执行的操作(调试与表格显示),您可以使用如下方式“漂亮地打印”阵列: 只要运行这个代码 您需要什么样的结果?所有内容?您要回显的内容和阵列数据是非对称的。了
foreach($array作为$value){
foreach($行的值){
if(is_数组($row)){
foreach($key=>$val的行){
回显$key.“=>”$val.“
”;
}///endForeach
}///恩迪夫
否则{
echo$行;
}////恩德斯
}
}
根据您尝试执行的操作(调试与表格显示),您可以使用如下方式“漂亮地打印”阵列:
只要运行这个代码
您需要什么样的结果?所有内容?您要回显的内容和阵列数据是非对称的。了解您需要从所有这些输入数组中获取哪些数据非常重要。一切?还是一部分?我想一部分一部分地和完整地分享并回应所有结果@WillParky93@alive到目前为止,你们试过什么了吗?我知道单数组的每个数组都常用,但它的嵌套数组..而且我是编码.plz的初学者help@Xatenevi尝试但显示错误“消息:数组到字符串转换”,控制器$data['query']。啊,缺少一个层,请立即重试您的代码有语法错误-->如果(是_数组($valueset){啊,更正了,其中一个括号丢失了它的匹配项实际上我在不同的表中使用搜索关键字代码:我有许多不同的表,没有共同的字段要加入;所以我给出seprate搜索查询和数组returnUpdated的结果…请现在尝试,谢谢它的工作..但是先生,我想在一个r上打印数组的结果下一行是嵌套数组…我是初学者,这就是plz帮助的原因。。
Array
(
[0] => Array
(
[0] => Array
(
[blog_title] => sooraj bloging
[blog_id] => 2
)
[1] => Array
(
[blog_title] => What are Mobile App Testing Challenges?
[blog_id] => 4
)
[2] => Array
(
[blog_title] => sooraj blog
[blog_id] => 8
)
)
[1] => Array
(
[0] => Array
(
[title] => sooraj casestudy
)
)
[2] => Array
(
[0] => Array
(
[career_id] => 14
[title] => Software Engineer .NET sooraj
[location] => Kochi, India.
[description] => Developing .NET applications.
[qualification] => B.Tech. in CSE, MCA
[status] => 0
[created_at] => 2017-11-20 13:14:29
[updated_at] => 0000-00-00 00:00:00
)
)
[3] => Array
(
)
[4] => Array
(
[0] => Array
(
[tst_id] => 146
[tst_name] => John Kasha
[tst_quote] => Gadgeon was extremely professional and was easy to commun sooraj icate and work with on a day-to-day basis. I also liked the fact that they were willing to do the research for specific tasks and present a viable solution or workaround to keep the project on schedule. I would recommend them for any task for any industry software or hardware. Bottom line, they get it done and you get results, not excuses. VP of Engineering.
[tst_desig] => Vice President,Product Development and Engineering
[tst_image] => 91c09ac9ee6234fdfcc523a393800bd5.jpg
[url] =>
[crop_name] => 668959f965ab28815dc97bbc1f8718d8.jpg
[sysDate] => 2017-11-20 15:42:34
)
)
)
foreach ($array as $value){
foreach ($value as $row){
if (is_array($row)){
foreach ($row as $key => $val){
echo $key."=>". $val."<br>";
}///endForeach
}///endIf
else {
echo $row;
}////endElse
}
}
// Assuming your array is $data
echo '<pre>'.var_export($data, TRUE).'</pre>';
// Assuming your array is $data
foreach ($data as $subdata) {
// You probably want to check that this is an array for case #3
if(is_array($subdata)) {
foreach ($subdata as $valueset) {
// Check for array validity (not required for example data, but good to be safe)
if (is_array($valueset)) {
foreach ($subdata as $key => $value) {
// Print each key, value pair as a row
echo $key .' => '.$value . '<br />';
}
}
}
} else {
// Optional handling of empty set
echo 'No data to display...';
}
}
<?php
$array = array(
array(
array(
'blog_title' => 'sooraj bloging',
'blog_id' => 2
),
array(
'blog_title' => 'What are Mobile App Testing Challenges?',
'blog_id' => 4
),
array(
'blog_title' => 'sooraj blog',
'blog_id' => 8
)
),
array(
array(
'title' => 'sooraj casestudy',
)
),
array(
array(
'career_id' => 14,
'title' => 'Software Engineer .NET sooraj',
'location' => 'Kochi, India.',
'description' => 'Developing .NET applications.',
'qualification' => 'B.Tech. in CSE, MCA',
'status' => 0,
'created_at' => '2017-11-20 13:14:29',
'updated_at' => '0000-00-00 00:00:00'
)
),
array(),
array(
array(
'tst_id' => 146,
'tst_name' => 'John Kasha',
'tst_quote' => 'Gadgeon was extremely professional and was easy to commun sooraj icate and work with on a day-to-day basis. I also liked the fact that they were willing to do the research for specific tasks and present a viable solution or workaround to keep the project on schedule. I would recommend them for any task for any industry software or hardware. Bottom line, they get it done and you get results, not excuses. VP of Engineering.',
'tst_desig' => 'Vice President,Product Development and Engineering',
'tst_image' => '91c09ac9ee6234fdfcc523a393800bd5.jpg',
'url' => '',
'crop_name' => '668959f965ab28815dc97bbc1f8718d8.jpg',
'sysDate' => '2017-11-20 15:42:34'
)
)
);
foreach ($array as $value){
foreach ($value as $row){
foreach ($row as $key=> $row1){
echo $key.' - '. $row1;
}
echo '<br>';
}
}
?>