How can I search for 50 characters before and after the keyword in PHP?
$ Content = strip_tags ($ content );
Preg_match ("/[^ u4e00-u9fa5] {} {$ keyword} [^ u4e00-u9fa5] {}/", $ content, $ m );
This is my original practice, and garbled characters will appear.
$ Keyword = "satisfied"; $ content = <
Service
We have always made work and welfare an important part of our comprehensive service delivery households, and are committed to the design order. test will meet the customer's needs, while saving costs and ensuring a high level of service providers.
Our work and welfare team will learn from you that your specific company needs to design a plan from the division and drawing components to meet your staff #39; needs, at the same time, keep in line with your strategy, budget, and market practices.
We need to actively participate in your staff welfare plan and implementation process. We hope to share with you a long-term approach to rethink the overall welfare strategy and help restore and improve the reality and feeling of the plan.
EOT;
Reply to discussion (solution)
preg_match("/[\w\W]{1,90}{$keyword}[\w\W]{1,90}/u", $content, $m);
preg_match("/[\w\W]{1,90}{$keyword}[\w\W]{1,90}/u", $content, $m);
There will be a bunch of spaces in front of some matched content
Then you can remove the space before matching.