в сорцах php вот что:
CODE (htmlphp):
скопировать код в буфер обмена
скопировать код в буфер обмена
- /* {{{ proto int similar_text(string str1, string str2 [, float percent])
- Calculates the similarity between two strings */
- PHP_FUNCTION(similar_text)
- {
- char *t1, *t2;
- zval **percent = NULL;
- int ac = ZEND_NUM_ARGS();
- int sim;
- int t1_len, t2_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|Z", &t1, &t1_len, &t2, &t2_len, &percent) == FAILURE) {
- return;
- }
- if (ac > 2) {
- convert_to_double_ex(percent);
- }
- if (t1_len + t2_len == 0) {
- if (ac > 2) {
- Z_DVAL_PP(percent) = 0;
- }
- RETURN_LONG(0);
- }
- sim = php_similar_char(t1, t1_len, t2, t2_len);
- if (ac > 2) {
- Z_DVAL_PP(percent) = sim * 200.0 / (t1_len + t2_len);
- }
- RETURN_LONG(sim);
- }
- /* }}} */