Click here to Skip to main content
15,901,426 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
AnswerRe: PHP with ODBC Connectivity Pin
cjoki6-Jun-10 9:52
cjoki6-Jun-10 9:52 
AnswerRe: PHP with ODBC Connectivity Pin
whatrevolution28-Jun-10 21:40
whatrevolution28-Jun-10 21:40 
QuestionHelp with this expression Pin
xx77abs4-Jun-10 2:59
xx77abs4-Jun-10 2:59 
AnswerRe: Help with this expression Pin
cjoki4-Jun-10 5:29
cjoki4-Jun-10 5:29 
GeneralRe: Help with this expression Pin
xx77abs4-Jun-10 5:34
xx77abs4-Jun-10 5:34 
GeneralRe: Help with this expression Pin
cjoki6-Jun-10 9:42
cjoki6-Jun-10 9:42 
GeneralRe: Help with this expression Pin
xx77abs6-Jun-10 10:22
xx77abs6-Jun-10 10:22 
GeneralRe: Help with this expression Pin
cjoki7-Jun-10 2:20
cjoki7-Jun-10 2:20 
I made a change to the code and got it to give the expected results.
foreach($test_array as $x)
{
    echo $x."<br>";
     if($x==0 && is_numeric($x))


The echo of $x shows it is (without the is_numeric function) stopping on "a", not what I would expect. Running the code with the is_numeric gives the correct result of index 9. I also tested === with the same results as the is_numeric.

Without spending more time researching this I can only assume that php is parsing "a" as being equal to 0. I suspect this maybe due to something the parser is doing to allow the testing of a string and an integer.

OK, I just did a little research and found this in the PHP manual...

String conversion to numbers
When a string is evaluated in a numeric context, the resulting value and type are determined as follows. 

If the string does not contain any of the characters '.', 'e', or 'E' and the numeric value fits into integer type limits (as defined by PHP_INT_MAX), the string will be evaluated as an integer . In all other cases it will be evaluated as a float . 

The value is given by the initial portion of the string . If the string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero). Valid numeric data is an optional sign, followed by one or more digits (optionally containing a decimal point), followed by an optional exponent. The exponent is an 'e' or 'E' followed by one or more digits. 

For more information on this conversion, see the Unix manual page for strtod(3).


A quick google on strtod shows me this...
Return Value
On success, the function returns the converted floating point number as a double value.
If no valid conversion could be performed, a zero value (0.0) is returned.
If the correct value is out of the range of representable values, a positive or negative HUGE_VAL is returned, and the global variable errno is set to ERANGE.
If the correct value would cause underflow, zero is returned and errno is set to ERANGE.


This looks to be the issue...but this is just a guess.
GeneralRe: Help with this expression Pin
cjoki7-Jun-10 5:25
cjoki7-Jun-10 5:25 
GeneralRe: Help with this expression Pin
xx77abs11-Jun-10 6:32
xx77abs11-Jun-10 6:32 
AnswerRe: Help with this expression PinPopular
User 17164924-Jun-10 6:33
professionalUser 17164924-Jun-10 6:33 
GeneralRe: Help with this expression Pin
cjoki6-Jun-10 9:45
cjoki6-Jun-10 9:45 
GeneralRe: Help with this expression Pin
xx77abs6-Jun-10 10:08
xx77abs6-Jun-10 10:08 
GeneralRe: Help with this expression Pin
whatrevolution22-Jun-10 23:52
whatrevolution22-Jun-10 23:52 
AnswerRe: Help with this expression Pin
whatrevolution23-Jun-10 0:13
whatrevolution23-Jun-10 0:13 
QuestionCloning a XLS worksheet in PHP Pin
Bijayani31-May-10 23:47
Bijayani31-May-10 23:47 
AnswerRe: Cloning a XLS worksheet in PHP Pin
Kristian Sixhøj3-Jun-10 7:29
Kristian Sixhøj3-Jun-10 7:29 
AnswerRe: Cloning a XLS worksheet in PHP Pin
Richard MacCutchan3-Jun-10 8:40
mveRichard MacCutchan3-Jun-10 8:40 
QuestionLearning Linux Pin
pc.bharti27-May-10 23:33
pc.bharti27-May-10 23:33 
AnswerRe: Learning Linux Pin
Richard MacCutchan28-May-10 0:10
mveRichard MacCutchan28-May-10 0:10 
GeneralRe: Learning Linux Pin
wbgxx21-Jun-10 3:58
wbgxx21-Jun-10 3:58 
AnswerRe: Learning Linux Pin
Iranian MM7-Sep-11 6:51
Iranian MM7-Sep-11 6:51 
QuestionPHP DOM Pin
vho12320-May-10 4:50
vho12320-May-10 4:50 
AnswerRe: PHP DOM Pin
Graham Breach20-May-10 7:06
Graham Breach20-May-10 7:06 
QuestionManaging a database insert failure.. Pin
MacIntyre19-May-10 4:57
MacIntyre19-May-10 4:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.