Applying PHP script to a file with multiple lines

Solution:
Well, I'd also advise reading php manual, however not foreach, but file() function. This could be done like:
<?php
foreach(file($argv[0]) as $line)
{
$arr = str_split($line, 2);
$strT = implode("", substr_replace($arr ,"",-1));
printf('%s:%s' . PHP_EOL, $str, $strT);
}
Answer
Solution:
For a command line solution, run this command:
while read str; do php -f myfun.php $str; done < strings.txt
where myfun.php is the following PHP script:
$arr = str_split($argv[1], 2);
$strT = implode("", substr_replace($arr ,"",-1));
printf('%s:%s' . PHP_EOL, $argv[1], $strT);
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: trying to access array offset on value of type null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.