タブで内破する前に、 array_values() 内の値からタグを取り除きたいです。
以下の行で試しましたが、エラーが発生しました。
$output = implode("\t",strip_tags(array_keys($item)));
理想的には、値から改行、ダブル スペース、タブを取り除き、
$output = implode("\t",preg_replace(array("/\t/", "/\s{2,}/", "/\n/"), array("", " ", " "), strip_tags(array_keys($item))));
しかし、私の方法は正しくないと思います!
これが関数全体です。
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));
$output .= "\n";
}
# create a line of values for this row...
$output .= implode("\t",array_values($item));
$output .= "\n";
# increment the row so we don't create headers all over again
$row++;
}
}
}
# return the result
return $output;
}
これを修正する方法があれば教えてください。ありがとう!