Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8622979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:10:45+00:00 2026-06-12T07:10:45+00:00

I use the following to take an array called $list and turn it into

  • 0

I use the following to take an array called $list and turn it into URLs:

function genIMG($sValue) {
return 'http://asite.com/'.$sValue.'?&fmt=jpg';
}
$IMGurls = array_map("genIMG", array_unique($list));
foreach($IMGurls as $imgLink) {
echo "<a href='". $imgLink ."'>". $imgLink ."</a><br />";
}

This works, but I also have some null values in the array. How can I have the array map ignore any values of null? Otherwise it just creates something like this:
http://asite.com/?&fmt=jpg with no file name since it was null.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:10:46+00:00Added an answer on June 12, 2026 at 7:10 am

    You $list must have contained empty values use array_filter

        $IMGurls = array_map("genIMG", array_unique(array_filter($list)));
    

    Example

    $list = array(1,2,3,4,5,"","",7);
    
    function genIMG($sValue) {
        return 'http://asite.com/' . $sValue . '?&fmt=jpg';
    }
    
    $IMGurls = array_map("genIMG", array_unique(array_filter($list)));
    foreach ( $IMGurls as $imgLink ) {
        echo "<a href='" . $imgLink . "'>" . $imgLink . "</a><br />";
    }
    

    Output

    http://asite.com/1?&fmt=jpg
    http://asite.com/2?&fmt=jpg
    http://asite.com/3?&fmt=jpg
    http://asite.com/4?&fmt=jpg
    http://asite.com/5?&fmt=jpg
    http://asite.com/7?&fmt=jpg
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to take an array of data called @users and turn it into
Take the following article for example: http://weblogs.asp.net/psteele/archive/2009/11/23/use-dependency-injection-to-simplify-application-settings.aspx?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+dotnetmvp+%28Patrick+Steele%27s+.NET+Blog%29 I don't see what benefit there is
so please take into account I am a newbie. I currently use the following
Hello Sir i want send list of data to php server i use following
I'm having an issue splitting a string array into a List/ArrayList. I realise this
How can I pass an array of filenames into the following method: public static
Take the F# following code: type Blah<'T>(objects : 'T array) as this = //
Take the following implementation of a array-based stack of chars for example: public char
Take the following example, class Cup {} class MyObject { protected $cups = array();
I am needing to turn a textfile into an array...I am not sure how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.