Please help - calling an external script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Smith

    Please help - calling an external script

    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


  • Erwin Moller

    #2
    Re: Please help - calling an external script

    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($mySpec ialChar,$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

    Comment

    • Erwin Moller

      #3
      Re: Please help - calling an external script

      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($myPart s);
      echo "</pre>";

      Comment

      • Sanders Kaufman

        #4
        Re: Please help - calling an external script

        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".

        Comment

        Working...