我正在使用自定义字段插件,我的代码必须自动填充它们,除2个字符串外,一切正常:
我获取字段的方式:
foreach($postMeta as $key => $dataTmp) {
if (strpos($key, \'field_\') !== false) {
$fieldData = unserialize($dataTmp[0]);
$fields[] = array(
\'field\' => $key,
\'name\' => $fieldData[\'name\']
);
}
}
顺便说一下,我正在填充它们:
foreach($fields as $name => $field){
if($field[\'name\'] == \'local_players\' && !empty($local_players)){
update_post_meta($postID, \'_\' . $field[\'name\'], $field[\'field\']);
update_post_meta($postID, $field[\'name\'], $local_players);
}elseif($field[\'name\'] == \'away_players\' && !empty($away_players)){
update_post_meta($postID, \'_\' . $field[\'name\'], $field[\'field\']);
update_post_meta($postID, $field[\'name\'], $away_players);
}else{
update_post_meta($postID, \'_\' . $field[\'name\'], $field[\'field\']);
update_post_meta($postID, $field[\'name\'], $data[\'Match.\'.$field[\'name\']]);
}
}
有问题的字符串是:
update_post_meta($postID, $field[\'name\'], $local_players);
update_post_meta($postID, $field[\'name\'], $away_players);
它们用空的meta\\u值填充数据库,而不是$local\\u players和$away\\u players的值。我已经检查过几次了,它们不是空的。
例如,它们的值如下所示:
string(66) "84168|84171|11206|84174|102117|32083|84189|84186|84193|17787|84195"
空字段的原因可能是什么?