*****~PLZ HELP~ ***我想对变量进行特殊化并采取类型,例如'注意'错误' ..在此代码中执行类似这样的事情
3710 a:6:{s:5:"%type&#34 ;; s:6:" Notice&#34 ;; s:8:"!message&#34 ;; s:24:"未定义变量:路径&#34 ;; s:9:"%功能&#34 ;; s:3:" l()&#34 ;; s:5: "%文件&#34 ;; S:44:" C&#34 ;; S:5:"%线&#34 ;; I:2469; S:14:" severity_level& #34 ;; I:5;}
3711 a:6:{s:5:"%type&#34 ;; s:6:" Notice&#34 ;; s:8:"!message&#34 ;; s:24:"未定义变量:路径&#34 ;; s:9:"%功能&#34 ;; s:3:" l()&#34 ;; s:5: "%文件&#34 ;; S:44:" / C&#34 ;; S:5:"%线&#34 ;; I:2511; S:14:" severity_level&#34 ;; I:5;}
3712 a:6:{s:5:"%type&#34 ;; s:7:"警告&#34 ;; s:8:"!message&#34 ;; s:141:"缺少l()的参数2,在第171行调用并定义&#34 ;; s:9:"%function&#34 ;; s:3:" l ()&#34 ;; S:5:"%文件&#34 ;; S:44:"&#34 ;; S:5:"%线&#34 ;; I: 2458; S:14:" severity_level&#34 ;; I:4;}
3713 a:6:{s:5:"%type&#34 ;; s:6:" Notice&#34 ;; s:8:"!message&#34 ;; s:24:"未定义变量:路径&#34 ;; s:9:"%功能&#34 ;; s:3:" l()&#34 ;; s:5: "%文件&#34 ;; S:44:"&#34 ;; S:5:"%线&#34 ;; I:2469; S:14:" severity_level& #34 ;; I:5;} **
function blabla_page() {
// Begin building
the query.
$query = db_select('watchdog', 'th')
->extend('PagerDefault')
->orderBy('wid')
->fields('th')
->limit(10);
// Fetch the result set.
$result = $query->execute();
// Loop through each item and add to the $rows array.
foreach ($result as $row) {
$rows[] = array(
$row -> wid,
$row -> variables,
);
}
// Headers for theme_table().
$header = array('ID', 'Message');
// Format output.
$output = theme('table', array('header' => $header, 'rows' => $rows)). theme('pager');
return $output;
}
答案 0 :(得分:2)
该字段中的信息是序列化的,应该这样做。
foreach ($result as $row) {
$message1=unserialize($row->variables);
if($message1['%type']){
$rows[] = array(
$row -> wid,
$message1['%type'],
);
}
}
现在输出只会在%类型项存在时添加到rows数组