탭을 사용하여 삽입하기 전에 array_values () 안의 값에서 태그를 제거하고 싶습니다.PHP : 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;
}
는 어떻게이 문제를 해결하는 아이디어가 있으면 알려 주시기 바랍니다. 감사!
고맙습니다. 이 기능은 Excel 파일을 내보내는 데 사용됩니다. 하지만 값에 태그, 줄 바꿈 등이있을 때 '버그'가 발생했습니다. – laukok