简体   繁体   中英

How to remove lines from textarea 1 which not contains each lines in textarea 2 ? [PHP]

Example

Textarea 1:

A123
B456
C789
D012

Textarea 2:

123
789

And when click button will show this result:

A123
C789

You can do something like below,

$data = ["A123","B456"];
$data1 = ["123"];
$newArr = array();
foreach($data1 as $val) {
    foreach($data as $fVal) {
        if(stristr($fVal,$val)) {
            $newArr[] = $fVal;
        }
    }
}

print "<pre>"; print_r($newArr);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM