相关疑难解决方法(0)

PHP:从array_values()中的值中剥离标记

我想在使用制表符进行内爆之前从array_values()内部的值中删除标记.

我试过下面的这一行,但是我有一个错误,

$output = implode("\t",strip_tags(array_keys($item)));
Run Code Online (Sandbox Code Playgroud)

理想情况下,我想剥离换行符,双倍空格,值的标签,

$output = implode("\t",preg_replace(array("/\t/", "/\s{2,}/", "/\n/"), array("", " ", " "), strip_tags(array_keys($item))));
Run Code Online (Sandbox Code Playgroud)

但我认为我的方法不正确!

这是整个功能,

function process_data($items){

    # set the variable
    $output = null;

    # check if the data is an items and is not empty
    if (is_array($items)  && !empty($items))
    {
        # start the row at 0
        $row = 0;

        # loop the items
        foreach($items as $item)
        {
            if (is_array($item) && !empty($item))
            {
                if ($row == 0)
                {
                    # write the column headers
                    $output = implode("\t",array_keys($item)); …
Run Code Online (Sandbox Code Playgroud)

php arrays preg-replace implode strip-tags

7
推荐指数
1
解决办法
8678
查看次数

标签 统计

arrays ×1

implode ×1

php ×1

preg-replace ×1

strip-tags ×1