Link to home
Create AccountLog in
Avatar of mhoggatt1
mhoggatt1

asked on

PHP print ascii space to browser

in this section of code that Ray sent me how can it be modified to print actual ASCII spaces to the browser instead of printing the non-ASCII characters?

Here is a section of the code:

// READ THE FILE A CHARACTER (OR A BYTE?) AT A TIME
$fpr = fopen($url, 'r');
if (!$fpr) trigger_error("Unable to read $url", E_USER_ERROR);
$cnt = 0;
while (!feof($fpr))
{
    $cnt++;
    $chr = fgetc($fpr);
    echo PHP_EOL . "$cnt $chr ";
    if (ord($chr) < 128) echo 'ASCII';
}

thanks,
Michael
SOLUTION
Avatar of noci
noci

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of mhoggatt1
mhoggatt1

ASKER

Thanks guys for the input.
Ray, I was just curious as to whether or not if the character wasn't in ascii format that I could print the ASCII spaces to the browser like you did in the getc routine you sent me. I was just curious about whether or not if the QT half-8 character could be replaced with the ASCII space then I could the result of the Bible verse from the browser, put it into a text file and then use the explode to see if that would work. Just thought I would tinker around with the program until you get back with me on the application you are working on for me.

Thanks,

Michael
Michael, perhaps I missed an email from you with the specs and test data?  I cannot work on anything without that!  I'm glad to help, but there's just no point in trying piecemeal to guess what data we are working with.  I'll stand by awaiting further information, including the test data.  Best regards, Ray
Michael: I hope you're still following this question thread.  I can't teach you advanced PHP concepts in an online forum like this one.  When we ask for test data, and we get test data that has been altered with the addition of hand-written commentary, we are handicapped by the damaged test case.  I urge you, if you want to write PHP code, to study the language and get some familiarity with the principles.  To that end, this article can help you find good learning resources.
https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html