简体   繁体   中英

Finder Class php - search keywords issue

I am working on symfony 2.7 and i am using finder class of php.

I am searching more then 1 keyword in the list of files.

I don't have any idea how to search more then 1 keyword using "contains" method of the finder class.

Below is my sample code.

$value = 'Leo Tiger';

$finder = new Finder();
$finder->in()->files()->contains($value);

My Concern is that i want to search "Leo" and "Tiger" both separately in diff files like elastic search will do.

How to use wildcard in finder method ?

I will really appreciate if anyone can help me this.

As you can see in comment to function contains the parameter $pattern can be (string or regexp). You can try use regex to find keywords Leo or Tiger:

$finder = new Finder();
$finder->in($dir)->files()->contains('/Leo|Tiger/');

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