By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,636 Members | 2,360 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,636 IT Pros & Developers. It's quick & easy.

Please help - calling an external script

P: n/a
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
Feb 2 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
Feb 2 '07 #2

P: n/a
Typo correction:
// now $myParts is an array that contains all pieces that are seperated by
the Q.
// check this:
echo "<pre>";
print_r();

print_r();
Should be
print_r($myParts);
echo "</pre>";

Feb 2 '07 #3

P: n/a
John Smith wrote:
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.
John - you're no newbie! Gosub went out in the seventies.

What you want is to write a function, and to call that function.

<?php

function fnHello($x) {
echo "Hello $x.";
}

fnHello("world");
?>

That would output "Hello world".
Feb 2 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.