获取数组键值

<?php
$arr=[
'name'=>'tom',
'age'=>'12',
'school'=>''
];

print_r(array_keys($arr)); //获取键
print_r(array_values($arr));<?php
$arr=[
'name'=>'tom',
'age'=>'12',
'school'=>''
];

print_r(array_keys($arr)); //获取键
print_r(array_values($arr));//获取值

数组拼合字符串

public function to_line($arrs){
$line = "";
foreach($arrs as $keys=>$vals){
$line .= $vals.'\t';
}
$line = rtrim($line, '\t');
echo $line.public function to_line($arrs){
$line = "";
foreach($arrs as $keys=>$vals){
$line .= $vals.'\t';
}
$line = rtrim($line, '\t');
echo $line."\n";
}

字符替换

<?php
// 把字符串 "Name\tAge\n" 中的字符 "\t" 替换为 ",":
echo str_replace("\t",",","Name\tAge\n");
<?php
// 把字符串 "Name\tAge\n" 中的字符 "\t" 替换为 ",":
echo str_replace("\t",",","Name\tAge\n");
?>