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 8385471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:40:48+00:00 2026-06-09T17:40:48+00:00

My code: $a = array_fill(5, 6, ‘banana’); prints Array ( [5] => banana [6]

  • 0

My code:

$a = array_fill(5, 6, 'banana');

prints

Array
(
    [5]  => banana
    [6]  => banana
    [7]  => banana
    [8]  => banana
    [9]  => banana
    [10] => banana
)

But I wanted it something like below

Array
(
    [5]  => banana 1
    [6]  => banana 2
    [7]  => banana 3
    [8]  => banana 4
    [9]  => banana 5
    [10] => banana 6
)

Is there any other php function there to achieve above? If yes, could you please let me know.

  • 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-09T17:40:49+00:00Added an answer on June 9, 2026 at 5:40 pm
    function test_print_value($item2, $key, $some_value)
    {
        echo $some_value." $item2<br />\n";
    }
    
    array_walk(range(0,10), 'test_print_value', 'Banana Apple ');
    

    Output:

    Banana Apple 0
    Banana Apple 1
    Banana Apple 2
    Banana Apple 3
    Banana Apple 4
    Banana Apple 5
    Banana Apple 6
    Banana Apple 7
    Banana Apple 8
    Banana Apple 9
    Banana Apple 10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If i hand code each array value like this: $paymentDetailsType->setPaymentDetailsItem( array ( 'PaymentDetailsItem00' =>
There is some problem, the code below assigning the last pr_name to all keys.
In my code an array is declared as follows private Object[,] cellInfos = new
I having two arrays say, $array1 = array(code => E0089, desc => some description);
My PHP code assigns an array to a Smarty variable that can be accessed
I have the following code $arr = array( 'media[]' => @{$image};type=image/jpeg;filename={$image} ); I do
Here is the code: $arraya = array('a','b','c'); foreach($arraya as $key=>$value) { if($value == 'b')
I have this php code $jsonArray = array(); $sql = SELECT ID,CLIENT FROM PLD_SERVERS;
This is the code for my array (which is working) Public numUsers As Integer
How to insert html code inside an array in PHP? I tried searching on

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.