Jump to content

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

i dont think so

 

because if I do just

 

<?php

foreach ($new_img_link as $img_link) {
echo $img_link;
}

?>

 

that outputs 50 different results of which I am looking for.

 

i dont see what looping those to lines would do but repeat code that is already in an array.

Link to comment
https://forums.phpfreaks.com/topic/109328-need-help-with-loop/#findComment-560822
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.