I understand the Idea of the solution until here-> "B so the-stealth will be theStealth." . But I don't understand the code and follow info . No offense. May be I don't understand PHP well or I am stupid.......
Yes you right, this part of my write-up is a bit 😵. This is actually an example I tried to show you, this is not a part of the solution, so if I want to recap:
🔎 First I find the pattern with this regex /(\-|\_)([a-z])/i.
It will find all _ or - followed by a character, like_c or _E or -a.
✏ Second I replace all these found matches with the equivalent uppercase character; So if we have _b this will be replaced by B! This is what I meant by _b => B.
I do the replacement with the preg_replace_callback function in PHP; Inside of each iteration the $match array contains, the matched string beside regex groups!
✔ We need to uppercase the character after _ or - so I use the second group of my regex, we can have access to that group in the second index of our array so I return strtoupper($match[2]) inside the callback function.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I understand the Idea of the solution until here-> "B so the-stealth will be theStealth." . But I don't understand the code and follow info . No offense. May be I don't understand PHP well or I am stupid.......
Hey there,
Yes you right, this part of my write-up is a bit 😵. This is actually an example I tried to show you, this is not a part of the solution, so if I want to recap:
🔎 First I find the pattern with this regex
/(\-|\_)([a-z])/i
.It will find all
_
or-
followed by a character, like_c
or_E
or-a
.✏ Second I replace all these found matches with the equivalent uppercase character; So if we have
_b
this will be replaced byB
! This is what I meant by_b => B
.I do the replacement with the
preg_replace_callback
function in PHP; Inside of each iteration the $match array contains, the matched string beside regex groups!✔ We need to uppercase the character after
_
or-
so I use the second group of my regex, we can have access to that group in the second index of our array so I returnstrtoupper($match[2])
inside the callback function.