Welcome Guest, Not a member yet? Register   Sign In
basic php problem.
#3

(This post was last modified: 05-24-2020, 08:53 AM by richb201.)

Thanks Rocs!.  I haven't done a var_dump (I pretty much really on the debugger). Here us one possibility:

foreach($results as $num => $row)  What is $row? is that the number of rows? Isn't an array indexed from zero?

[0]='first'
[1]='second'
[2]='third'
So if $row returns 3 (in this case), $row[3] is pointing at a row that doesn't exist. I have never seen that foreach value ($row) used as an index. I guess the question is " in PHP, are array indexes zero based?". BTW I am using PHP 7.0. I see this note about foreach. What does it mean? 

Quote:As [i]foreach[/i] relies on the internal array pointer in PHP 5, changing it within the loop may lead to unexpected behavior.
In PHP 7, [i]foreach[/i] does not use the internal array pointer.
I guess the question is what is $row assigned by foreach($results as $num => $row) ? Is it  a pointer like it would be in "C" as in &row, Or is it an integer? I am assuming that it will be an int, but I really don't know. The next line in the code it is used like this 

$image_filename = $row->{$this->url_field};

Which makes me thinks that it is a pointer. Perhaps it should be used like this? 
$current=$row(count) and then
$image_filename $row[current].url_field};
proof that an old dog can learn new tricks
Reply


Messages In This Thread
basic php problem. - by richb201 - 05-23-2020, 06:37 PM
RE: basic php problem. - by php_rocs - 05-24-2020, 02:54 AM
RE: basic php problem. - by richb201 - 05-24-2020, 08:23 AM
RE: basic php problem. - by InsiteFX - 05-24-2020, 08:50 AM
RE: basic php problem. - by richb201 - 05-24-2020, 09:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB