Add text to each element of array
Basically what I am trying to do is add text before (and after) each
element of an array. This is an example:
<?php
$word="code";
$chars=preg_split('//', $word, -1, PREG_SPLIT_NO_EMPTY);
print"<pre>";
print_r($chars);
print"</pre>";
?>
(Yes I need the regex so I can't just use str_split())
which outputs:
Array
(
[0] => c
[1] => o
[2] => d
[3] => e
)
Now my ultimate goal is to get the final string to be something like:
"shift+c","shift+o","shift+d","shift+e"
If I can get help just adding the "shift+ in front of each element, then I
can use implode() to do the rest.
No comments:
Post a Comment