|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
does substr_count work?
heres the deal, I'm using a bit of code:
$x = substr_count($word, $guess); Imagine the game hangman, you want to know if the letter you guessed is in the hidden word. Using echos I can prove that, for example $word = akira and $guess = a and $x = 0 Naturally I'm not pleased, I tried switching the variable order, which is wrong and it does exactly the same. I'm open to suggestions as to why it might not be working and fixes, at present I'm hoping to avoid writing a loop to go through each character checking the whole word and figuring out what to do at the end but thats mostly because I am lazy. Alan Bundock gamer extrordinaire. But that don't mean I'm good |
|
#2
|
|||
|
|||
|
RE: does substr_count work?
This code:
works as expected for me. It echos out the number 2. Can you show some example code that doesn't work? |
|
#3
|
|||
|
|||
|
RE: does substr_count work?
Okay I was using substr_count in an if statement, i.e. if it returned a count greater than zero. By creating a variable first, performing the operation and then using the new variable in the if statement it seems to be working. Why this should make a difference I'm not sure.
Once again thanks for your contributions. Alan Bundock |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > does substr_count work? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|