[ create a new paste ] login | about

Link: http://codepad.org/OoY29N7w    [ raw code | output | fork ]

PHP, pasted on Mar 21:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php

$str = 'Example: hello world, this world rocks.
What it should do is: 
if it finds the word hello it should
remove the whole line. How can i do that and there 
could be words in between brackets and inverted commas also.';

$lines = explode("\n", $str);

foreach($lines as $index => $line) {

   if (strstr($line, 'hello')) {
      unset($lines[$index]);
   }

}

$str = implode("\n", $lines);

var_dump($str);


Output:
1
2
3
string(137) "What it should do is: 
remove the whole line. How can i do that and there 
could be words in between brackets and inverted commas also."


Create a new paste based on this one


Comments: