/ PHP / 상세보기

trim — Strip whitespace (or other characters) from the beginning and end of a string

👁 조회 4,184 📅 2010-01-19 🔗 참고사이트
string trim ( string $str [, string $charlist ] )

Example #1 Trimming array values with trim()

<?php
function trim_value(&$value


    
$value trim($value
); 
}

$fruit = array('apple','banana '' cranberry '
);
var_dump($fruit
);

array_walk($fruit'trim_value'
);
var_dump($fruit
);

?>

Example #2

<?php
$string
= 'This string  has   no    whitespaces.'
;
echo
ereg_replace( ' +', '', $string
);
?>
Output: Thisstringhasnowhitespaces.

💬 댓글 1개

2010-01-19
if(!$auth[admin]) {
$rg_name = ereg_replace( ' +', '', $rg_name );
$rg_name=substr($rg_name,0,4)."○";
}