I don't know PHP but bash should do something like one post of the top-related on the right side:
#!/usr/bin/env bash
declare line ; line=
declare -a line_ ; line_=()
while IFS= read -r line ; do
line_+=( "${line}" )
done < /dev/stdin
printf "%s\n" "${line_[@]}"
Assumed the script's name is some_script.sh
you can do
% echo '&Ω↑ẞÐĦØđ¢ø' | bash some_script.sh
&Ω↑ẞÐĦØđ¢ø
while IFS= read -r line
is explained here: Bash, read line by line from file, with IFS
and on the bash wiki
- IFS is set to the empty string to prevent read from stripping leading and trailing whitespace from each line. – Richard Hansen
- -r raw input - disables interpretion of backslash escapes and line-continuation in the read data