Jump to content

need help with loop


MikeDXUNL

Recommended Posts

Didn't you already ask this in another thread?

 

You are updating achimg with $img_link which is an iteration of $new_img_link which is supposed to be an array but here:

 

$new_m = strrchr($m[0], '/');
$new_img_link[] = $new_m;

 

strrchr starts at the last occurance of the needle in the haystack and returns from there until the end of the haystack; that is, a string is being returned, so your $new_img_link is not really an array. Well, it's an array with 1 position, which makes it a glorified variable.  So your foreach loop isn't doing squat but iterating once.

Link to comment
https://forums.phpfreaks.com/topic/109328-need-help-with-loop/#findComment-560806
Share on other sites

umm..hmm. I don't really see how that loop could possibly be giving you 50 different results...I mean, the code you posted in that link clearly shows you making $new_img_link an array with only one position...have you changed your code somehow since then?

 

But regardless, you have your query outside the foreach loop, so no matter how many positions are in that array, $img_link is going to be the last iteration of that loop, and your query is going to insert that last iteration value on every single iteration on your outer foreach loop.

Link to comment
https://forums.phpfreaks.com/topic/109328-need-help-with-loop/#findComment-560829
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.