Web >> Development >> PHP >>  How to search all single characters in a string

<?php $string = "cdef"; $result = preg_match_all("/\w/U",$string,$matches); foreach ( $matches[0] as $k => $v ) { printf("%d,%d %s\n",0,$k,$matches[0][$k]); } ?>