We help IT Professionals succeed at work.
Get Started

Conditional statement

mhoggatt1
mhoggatt1 asked
on
105 Views
Last Modified: 2016-01-31
Back in the 70s my programming experience was in assembly language. So I am not programming anymore having been retired for some time. I am barely familiar with PHP and need your expert help in writing a simple text file routine that will be a help to me in my Bible study.

      I copy and paste the Scripture verse into a text file called strongs.txt and this is what the text file looks like:

Matthew 5:5 Blessed 3107  are the meek: 4239  for 3754  they 846  shall inherit 2816 5692  the earth 1093 .

This is a simple routine that I copied off the Internet and that's as far as I've been able to go and I'm not sure if it will even work for what I need to do or not:

<?php
$myfile = fopen("strongs.txt", "r") or die("Unable to open file!");
// Output one character until end-of-file
 while(!feof($myfile)) {
   echo fgetc($myfile);}

fclose($myfile);
?>

And it does print out the file strongs.txt when run in my browser.

Here is the format I need the file to be in:
Matthew 5:5 Blessed 3107 
are the meek: 4239 
for 3754 
they 846 
 shall inherit 2816 5692 
the earth 1093 .

The text file strongs.txt and the word phrase associated numbers are separated by double spaces. So I would presume some kind of conditional statement would be needed to test for the double spaces then print the line into a new file with a return to place them on separate lines. Not being familiar with PHP what would you suggest? Any coding that would complete this routine would be greatly appreciated. Hope this all makes sense,

Michael
Comment
Watch Question
Most Valuable Expert 2011
Author of the Year 2014
Commented:
This problem has been solved!
Unlock 4 Answers and 20 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE