Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php foreach结果在同一行上_Php_Html_Css - Fatal编程技术网

Php foreach结果在同一行上

Php foreach结果在同一行上,php,html,css,Php,Html,Css,我有以下代码: foreach ($ck as $k) { if (substr ($k, 0, 1) == '_') { // skip keys starting with '_' continue; } $cv = get_post_custom_values($k, $post_id ); //Array foreach ($cv as $c) {

我有以下代码:
    foreach ($ck as $k) {
         if (substr ($k, 0, 1) == '_')
         {   // skip keys starting with '_'
             continue;
         }
         $cv = get_post_custom_values($k, $post_id );  //Array

            foreach ($cv as $c) {
                if (empty ($c))
                {   // skip empty value
                    continue;
                }
                $format_c =  $c;

                print_r ('<div style="font-size: 14px;">'.$k .': '. $format_c . ' / </div>');

            }
    }

?>
如何将代码更改为具有:

something: result / something: result / something: result /
谢谢

A是块级元素。改用像
这样的内联元素

    foreach ($ck as $k) {
         if (substr ($k, 0, 1) == '_')
         {   // skip keys starting with '_'
             continue;
         }
         $cv = get_post_custom_values($k, $post_id );  //Array

            foreach ($cv as $c) {
                if (empty ($c))
                {   // skip empty value
                    continue;
                }
                $format_c =  $c;

                echo "<span style='font-size: 14px;'>$k: $format_c / </span><br/>";

            }
    }

?>
foreach($ck作为$k){
如果(substr($k,0,1)='')
{//跳过以“\”开头的键
继续;
}
$cv=get_post_custom_值($k,$post_id);//数组
foreach($cv为$c){
如果(空($c))
{//跳过空值
继续;
}
$format_c=$c;
echo“$k:$format_c/
”; } } ?>
另外,我不认为
print\u r()
做你认为它做的事情。或用于输出文本。

foreach($k为ck){
foreach ($ck as $k) {
     if (substr ($k, 0, 1) == '_')
     {   // skip keys starting with '_'
         continue;
     }
     $cv = get_post_custom_values($k, $post_id );  //Array

      echo '<div style="display: inline; font-size: 14px;">';
        foreach ($cv as $c) {
            if (empty ($c))
            {   // skip empty value
                continue;
            }
            $format_c =  $c;

            print_r ($k .': '. $format_c . ' /);

        }echo '</div>';
}
如果(substr($k,0,1)='') {//跳过以“\”开头的键 继续; } $cv=get_post_custom_值($k,$post_id);//数组 回声'; foreach($cv为$c){ 如果(空($c)) {//跳过空值 继续; } $format_c=$c; 打印($k.:'.$format_c./); }回声'; }

?>

有什么区别?不要将其放入
更改DIV的CSS,使其显示为
inline
@thecodese格式混乱,第一组3个结果之间应该有换行符。
foreach ($ck as $k) {
     if (substr ($k, 0, 1) == '_')
     {   // skip keys starting with '_'
         continue;
     }
     $cv = get_post_custom_values($k, $post_id );  //Array

      echo '<div style="display: inline; font-size: 14px;">';
        foreach ($cv as $c) {
            if (empty ($c))
            {   // skip empty value
                continue;
            }
            $format_c =  $c;

            print_r ($k .': '. $format_c . ' /);

        }echo '</div>';
}