Jump to content

reading in and stopping


desmondMorris

Recommended Posts

hi

 

i am using the following code:

 

if(preg_match_all('%read (?P<words>\w+)%i', $text, $out)) {...

 

i want to be able to print whatever is written aftet the word 'read' is used, this is working fine so far, however currently only the first word after 'read' is being printed. i want to be able to print the whole line, up until a ';' is seen.

 

does anyone have any ideas on this?

 

cheers in advance

 

des.

Link to comment
https://forums.phpfreaks.com/topic/193098-reading-in-and-stopping/
Share on other sites

text is input into a form, when its submitted, wherever the word 'read' is found, the next word is printed. it works fine. this is the full code ive got:

 

<?php

if(isset($_POST['submit'])){

 

$text = $_POST['txt'];

if(preg_match_all('%read (?P<words>\w+)%i', $text, $out)) {

 

    $words = $out['words'];

}

//echo '<pre>'.print_r(get_defined_vars(), true).'</pre>';

if(isset($words)) {

 

$arrayAmount = count($words);

 

      for ($i=0;$i<=$arrayAmount;$i++){

      echo "$words[$i]\n";     

      }

}

 

 

}

?>

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.