|
Posted by Erwin Moller on 02/02/07 08:04
John Smith wrote:
> Hi All,
>
> I have a script which reads a data file, reads the characters one by one
> and if a certain character is meet it does something else, at the moment
> it echos the fact that it meet a certain character.
>
> I need it to take the characters it has read up to that point and present
> them to a database field thats forms part of a set of fields that will be
> updated at once. Then it will continue to read the remainder of the file
> and repeat the process until it reaches eof.
>
> Is there something similar to goto or gosub, I did some checking and was
> laughed at, as you can probably tell I'm a newbie. Maybe I should be
> calling an external script? Any assistance is gratefully accepted.
>
> Cheers
Hi John,
Sorry about the laughing, but using goto is not done. It is errorprone and
unneeded since all things can be programmed in another (better/more
structured) way. Goto is send to the Valley Of The Lost Bits a long time
ago. Just don't mention it: Programmers tend to get all freaked up if you
just say 'goto'. ;-)
About your problem:
// define your special character, (just guessing)
$mySpecialChar = "Q";
$myText = "This is a long piece of Q text.Q blaQbla2Qand even more bla."
$myParts = explode($mySpecialChar,$myText);
// now $myParts is an array that contains all pieces that are seperated by
the Q.
// check this:
echo "<pre>";
print_r();
echo "</pre>";
Does that help?
Also: 'Goto' www.php.net, and search for the function explode for details.
Good luck!
Regards,
Erwin Moller
[Back to original message]
|