I have this: foreach (array_combine($img, $name) as $img => $title) { echo $img; echo $title; } PHP: The problem is that array_combine will remove duplicates. So, if I have two ore more entries like this image1 name1 image1 name1 It will only show them once. I need to be able to print them on each occurrence. How can I do that? Thanks!
That doesn't see to do that I want.. Now if I echo $title all the titles are in one line.. Like title1title1title1
You question is also a but confusing. Kindly post example of input and desired out and we can advise thanks
I have two textarea fields in a form. One is images and the 2nd is names. I need to echo the output like this: echo $image; echo $name; The problem occurs if I have this in my textareas In names: test test test In images: img1 img1 img1 The array_merge works great if I have no duplicates. In the case presented above, my echo is this: test img1 it should be test img1 test img1 test img1 Was I clear enough this time? I'm not very good in explaining and my English is not so good either.. [EDIT] Sorry, I meant array_combine works great if..
Your English is very fine And problem is because array can hold one unique key not multiple of same name .. foreach ($images as $key => $img) { $title = $titles[$key]; //note this echo $img; echo $title; } PHP:
Can you please write down the solution? So that will be helpful for me ... I am doing this with alot of code....
I'm just stuck trying to figure out what in the blazes you're trying to accomplish with that... nothing in this thread makes the least bit of sense to even be doing in the first place.
And... How does that make sense to have several files named the same? This is anyway why we have ways to manipulate a filesystem...
Yes, but WHAT name?!? Do you have a list of names to replace them with or are you just blindly going to rename them all the same (which is what it sounds like)... Doesn't make any sense. Sure as shine-ola doesn't sound like anything that can be automated unless your intent is to change their name to their title, and that's still a loaded gun to your head given the probability of collisions. (duplicate names).
You should post the solution too, here is mine in the event someone else comes to this thread: function combine_custom($key, $val){ return array('img' => $key, 'title' =>$val); } $results = array_map('combine_custom', $img, $name); foreach ($results as $row) { echo $row['img']; echo $row['title']; } PHP: