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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:13:21+00:00 2026-06-01T11:13:21+00:00

Is there a way to explode a string into variables e.g some_function($min, $max, 3,

  • 0

Is there a way to explode a string into variables e.g

some_function($min, $max, "3, 20");

such that $min is assigned the value 3 and $max is assigned the value 20.

I know I can simply use

$data = explode("3, 20");

just wondering if there is another way.

  • 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-01T11:13:22+00:00Added an answer on June 1, 2026 at 11:13 am

    PHP’s language construct list() can perform multiple assignments to variables (or even other array keys) by assigning an array.

    list($min, $max) = explode(",", "3,20");
    

    However, you would still need to apply a trim() to your variables since the $max value would have a leading space, or replace explode() with preg_split('/\s*,\s*/', $string) to split it on commas and surrounding whitespace.

    Note: Use caution with list() to be sure that the array you’re assigning contains the same number of elements as list() has variables.

    In PHP 5.x, when assigning a value directly to another array, as an element of that array, list() values are assigned from right to left in PHP 5.x, not left to right. In other words, you’ll end up with array that is populated backwards (last value, first).

    https://www.php.net/manual/en/migration70.incompatible.php

    In PHP 7.x list() arguments are assigned from left to right, when assigning elements directly to an array. In other words, you’ll end up with the first value as the first element in the recipient array.

    <?php
        list($a[], $a[], $a[]) = [1, 2, 3];
        var_dump($a);
    ?>
    

    PHP Manual

    PHP 5.X Last value gets the first element position, but the recipient must an array (in this case $a, is the array)!

    array(3) {
      [0]=>
      int(3)
      [1]=>
      int(2)
      [2]=>
      int(1)
    }
    

    PHP 7.x First value becomes the first array element.

    array(3) {
      [0]=>
      int(1)
      [1]=>
      int(2)
      [2]=>
      int(3)
    }
    

    PHP Manual

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there way that I can read the file from remote server using fopen
I have a string category=45&format=1 that I want to convert into a key=value array.
Is there a way you can add a column to the Details view of
I want to split a string into two variables, the first word and the
Is there any way to explode() using an array of delimiters? PHP Manual: array
I have to convert a long string of data into values so that I
I know that there are REGEXP_ functions, but this ones return maximum 1 row
Is there any way to have PHP output a string with the \r\n and
I have a string similar to belows: a_b_c_d_1 x_y_z_12 Now, you can see that
is there a way to get the n-th element of a splitted string without

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.