How to solve this problem by finding the php title and saving it to a field

Source: Internet
Author: User
I want to add a low-level keyword function for a php applet, just like the word segmentation effect when the php applet is easy to collect. for example, the title is: I have never seen Altman's automatic word segmentation result: I have never | ever | AO | OT | man I tried php's segmentation function myself, however, the split is a very painful array. if you are depressed, please give me some advice! I did not have a basic php, but I just read a little introduction! I thought like this $ title. I never saw the php split title and saved it to the code in a field.
I want to add a low-level keyword function for a php applet, just like the word segmentation effect when it is easy to collect. for example, the title is: I have never seen Altman.

The result of automatic word segmentation is: I have never | never seen | ever | Aote | man


I tried the segmentation function of php myself, but it is a painful array after the segmentation. I'm depressed. please give me some advice!

I did not have a basic php, but I just read a little introduction!

I think so.

$ Title = I have never met Altman

$ Keyword = str_split ($ title, 1 );

However, the split is an array, and the split seems to be changed to: me | from | not | see | past | Austria | Te | man

How can we generate results like automatic keyword generation for easy collection!

------ Solution --------------------
First. Note that it is UTF-8 encoded.
PHP code
$ Title = 'I have never seen Altman'; $ len = mb_strlen ($ title, 'utf-8'); $ l = 0; while ($ l <$ len-1) {$ arr [] = mb_substr ($ title, $ l, 2, 'utf-8'); $ l ++;} echo join ('|', $ arr );
------ Solution --------------------
You can install SCWS Chinese word segmentation system, which is available in Windows and linux and can be used as an extension of php. After the installation, use phpinfo to check whether scws is successful.
Example:
$ Sh = scws_open ();
Scws_set_charset ($ sh, 'gbk ');
Scws_set_multi ($ sh, SCWS_MULTI_SHORT | SCWS_MULTI_DUALITY | SCWS_MULTI_ZMAIN | SCWS_MULTI_ZALL );
$ Text = "I have never met Altman ";
Scws_send_text ($ sh, $ text );
$ Top = scws_get_tops ($ sh, 10 );
Print_r ($ top );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.