Hello,
I have two arrays
$keyword= array() //actually this is a word, that you must guess letter by
letter
and
for ($i = 0; $i < count($keyword); $i++) { //make equal word and keys array
length
$keys[] = '*';
if my word is 'foobar' , keys array will show ******
so i want to input a letter and if it exists in the word, to add and replace
in $keys array.
for instance, input 'o' >>*oo***
the code i tried
$findme = $this->data['Word']['find'];
$keyword = str_split($word[0]);
for ($i = 0; $i < count($keyword); $i++) {
$keys[] = '*';
}
$this->set('keys', $keys);
if (in_array($findme, $keyword)) {
$pos = strpos($word[0], $findme);
$replace = str_replace($keys, $pos,$findme);
$new_word = array_push($keyword, $findme); //searches a string in array
$pos = strpos($word[0], $findme);
$key[$pos] = $findme; //finds a character pos in string
}
actually it deals with php functions, that i don't get, will anyone help?
sorry for bad explanation and code, i need this as soon as possible :)
thanks
--
View this message in context: http://cakephp.1045679.n5.nabble.com/Replace-an-element-in-array-tp5714737.html
Sent from the CakePHP mailing list archive at Nabble.com.
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Wednesday, May 1, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment