Voglio rimuovere le tag dal valore all'interno di array_values () prima di implodere con le schede.PHP: elimina i tag dal valore all'interno di array_values ()
Ho provato con questa linea di seguito ma ho un errore,
$output = implode("\t",strip_tags(array_keys($item)));
idealmente voglio togliere le interruzioni di linea, doppi spazi, tabulazioni dal valore,
$output = implode("\t",preg_replace(array("/\t/", "/\s{2,}/", "/\n/"), array("", " ", " "), strip_tags(array_keys($item))));
ma pensa che il mio metodo non sia corretto!
questo è l'intera funzione,
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;
}
Per favore fatemi sapere se avete qualche idea su come risolvere questo problema. Grazie!
grazie per questo! questa funzione viene utilizzata per esportare i file Excel. ma ha causato "bug" quando ho tag, interruzioni di linea, ecc nel valore. – laukok