Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
533 views
in Q2A Core by

In the file qa-include/util/string.php there is this function:

function qa_string_to_words($string, $tolowercase = true, $delimiters = false, $splitideographs = true, $splithyphens = true)
{
    if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }

    global $qa_utf8punctuation;

    if ($tolowercase)
        $string = qa_strtolower($string);

    $string = strtr($string, $qa_utf8punctuation);

    $separator = QA_PREG_INDEX_WORD_SEPARATOR;
    if ($splithyphens)
        $separator .= '|\-';

    if ($delimiters) {
        if ($splitideographs)
            $separator .= '|' . QA_PREG_CJK_IDEOGRAPHS_UTF8;

    } else {
        $string = preg_replace("/(\S)'(\S)/", '\1\2', $string); // remove apostrophes in words

        if ($splitideographs) // put spaces around CJK ideographs so they're treated as separate words
            $string = preg_replace('/' . QA_PREG_CJK_IDEOGRAPHS_UTF8 . '/', ' \0 ', $string);
    }

    return preg_split('/(' . $separator . '+)/', $string, -1, PREG_SPLIT_NO_EMPTY | ($delimiters ? PREG_SPLIT_DELIM_CAPTURE : 0));
}

 How can i create a new function for letters/characters instead of words. I want a new function like: 


function qa_string_to_letters($string, $tolowercase = true, $delimiters = false, $splitideographs = true, $splithyphens = true)
 

I hope that someone of the developer like Puppi, Scott or anyone else could help me with this. Thanks everybody.

Q2A version: 1.8.6
by
Splitting a string into characters is relatively simple: $char_array = str_split($string).

Howevre, I have a feeling this might be an X-Y question, so please take a step back and describe the actual problem you're trying to solve instead of what you perceive as the solution. What do you need this function for?
by
Thank you Ansgar. Your comment is helpful
 I ll let you know if I need further assistance. Cheers

Please log in or register to answer this question.

...