如何在codeigniter视图

时间:2017-11-20 11:35:53

标签: php mysql codeigniter

  

预先知道此数组结果并回显结果

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
            )

    )

)

3 个答案:

答案 0 :(得分:2)

只需运行此代码

Vlookup

答案 1 :(得分:1)

根据您尝试做的事情(调试与表格显示),您可以"漂亮的打印"像var_export这样的数组如下:

// Assuming your array is $data
echo '<pre>'.var_export($data, TRUE).'</pre>';

否则,按照foreach

循环遍历数组
// 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...';
    }
}

答案 2 :(得分:0)

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
}
}