Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,938 questions

51,875 answers

573 users

How to find all lowercase characters in a string with PHP

2 Answers

0 votes
$str = "JavaScript C C++ PHP NodeJS";
$size = strlen($str);

for ($i = 0; $i < $size; $i++) {
    if ($str[$i] >= 'a' && $str[$i] <= 'z')
        echo $str[$i] . ' ';
            
}





/*
run:

a v a c r i p t o d e 

*/

 



answered Apr 20, 2022 by avibootz
0 votes
$str = "JavaScript C C++ PHP NodeJS";

preg_match_all('/[a-z]/', $str, $matches, PREG_OFFSET_CAPTURE);

print_r($matches[0]);





/*
run:

Array
(
    [0] => Array
        (
            [0] => a
            [1] => 1
        )

    [1] => Array
        (
            [0] => v
            [1] => 2
        )

    [2] => Array
        (
            [0] => a
            [1] => 3
        )

    [3] => Array
        (
            [0] => c
            [1] => 5
        )

    [4] => Array
        (
            [0] => r
            [1] => 6
        )

    [5] => Array
        (
            [0] => i
            [1] => 7
        )

    [6] => Array
        (
            [0] => p
            [1] => 8
        )

    [7] => Array
        (
            [0] => t
            [1] => 9
        )

    [8] => Array
        (
            [0] => o
            [1] => 22
        )

    [9] => Array
        (
            [0] => d
            [1] => 23
        )

    [10] => Array
        (
            [0] => e
            [1] => 24
        )

)

*/

 



answered Apr 20, 2022 by avibootz
...