php - Adding code to every character within a string -
i need create 'word search' puzzle, if hover on word, changes colour, can find ease. that, have split searching part , words in separate arrays
. want add x
every character, 'x'
being random character.
i have no knowledge of codes can me achieve this.
a part of puzzle:
-e-------------a--e-
-k--galabal---a---l-
-e-----------t----t-
-n-straatlantaarn-o-
-diuleg-----------u-
----kade----------w-
computer------------
(without breaklines)
with computer, galabal, straatlantaarn, geluid, kade , others words need searched. puzzle 20 x 20 characters.
i try point in right direction, without spoon-feeding code.
heres algorithm.
- use
explode
whitespace
characterdelimiter
split words of string array. - loop through array elements , start creating
html
output. - for each word, prepend
<span class="word-highlight">
. - and append each word
</span>
- remember append whitespace while re-creating sentence.
- also keep logic handles full stops , pronouns etc handy.
- now write
css
code handle:hover
event of mouse on respective class (.word-highlight
in our case), , subsequently change color.
Comments
Post a Comment