Voting

: two plus seven?
(Example: nine)

The Note You're Voting On

gbelanger at exosecurity dot com
18 years ago
True, the Perl chomp() will only trim newline characters. There is, however, the Perl chop() function which is pretty much identical to the PHP rtrim()

---

Here's a quick way to recursively trim every element of an array, useful after the file() function :

<?php
# Reads /etc/passwd file an trims newlines on each entry
$aFileContent = file("/etc/passwd");
foreach (
$aFileContent as $sKey => $sValue) {
$aFileContent[$sKey] = rtrim($sValue);
}

print_r($aFileContent);
?>

<< Back to user notes page

To Top