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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:41:56+00:00 2026-05-13T14:41:56+00:00

i want to set my array key initial value to a certain number. here

  • 0

i want to set my array key initial value to a certain number.
here is what i have:

$tickets=array();
array_push($tickets,"10","20","TBD")

for($i=3; $i<20; $i++)

i want my array initial value to start at 3 not 0.

any ideas

  • 1 1 Answer
  • 1 View
  • 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-05-13T14:41:56+00:00Added an answer on May 13, 2026 at 2:41 pm

    If you’re initializing $tickets right there why not use an array literal?

    $tickets=array(3=>10, 4=>20, 5=>'TBD');
    print_r($tickets);
    

    prints

    Array
    (
        [3] => 10
        [4] => 20
        [5] => TBD
    )
    

    edit and btw: This also works with variables in both places, the key and the value. Therefore

    $x = 5;
    $y = 'TBD';
    $tickets=array(3=>10, 4=>20, $x=>$y);
    print_r($tickets);
    

    has the same output as well as

    $tickets=array( /* initial index here */ 3=>10, 20, 'TDB');
    print_r($tickets);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couchdb view set up using an array key value, in the
I want to define an interface IFile that includes an array of key/value pairs
I have a form and when I want to set the primary key, I
Initial conditions: DateTime moment string key double value somewhere across the code i want
I want to set a property of an object that is an array type.
I got a result set in array format and i want to make square
I'm going to be getting an array of objects and want to set instance
I want set Listbox background to transparent but not working Is there any idea?
My question is : I have an EditText and I want set a margin
i have a problem, i want set text of a UILabel or UItextView or

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.