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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:29:09+00:00 2026-05-17T22:29:09+00:00

Just a quick newbie PHP syntax question. I have a variable, let’s call it

  • 0

Just a quick newbie PHP syntax question.

I have a variable, let’s call it $tabs which always contains a string of numbers separated by commas, like so: 24,35,43,21

I also have a variable that’s an array:

$args = array('post_type' => 'page', 'post__in' => array(27,19,29), 'order' => 'ASC');

That’s of course WordPress. What I need to do, is place the content of the $tabs variable (numbers) where the numbers inside the array are. I’m rather new to PHP, only understand how to modify some things, but this I can’t figure out, no idea how the syntax for it should go.

Anyone able to help? Thanks.

  • 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-05-17T22:29:10+00:00Added an answer on May 17, 2026 at 10:29 pm
    $args['post__in'] = array_merge($args['post__in'], explode(',', $tabs));
    

    Let’s explain what I did so you may pick up a thing or two:

    1. explode(',', $tabs) splits a string into pieces at a separator and puts that pieces in an array.
    2. array_merge($arr1, $arr2) will merge the two arrays.
    3. $args['post__in'] will access an array element specified by a key.

    Note that array_merge, in this case, will just append the values and you may end up with duplicate numbers. To get rid of duplicates just wrap the merge in array_unique. Like so:

    $args['post__in'] = array_unique(array_merge($args['post__in'], explode(',', $tabs)));
    

    And of course, the trivial case when you just want to replace those numbers with brand new ones is

    $args['post__in'] = explode(`,`, $tabs);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

just a quick question: I am a CS undergrad and have only had experience
just a quick question, if I have a matrix has n rows and m
Just a quick database design question: Do you ALWAYS use an ID field in
Just a quick question. I want to send data from Javascript to a PHP
Just a quick query really, In my PHP file, I have variables coming from
Just a quick question: What are people's practices when you have to define the
I am working with a huge list of URL's. Just a quick question I
Good morning, Apologies for the newbie question. I'm just getting started with ASP.NET internationalization
Just a quick question here: If I choose the object oriented style to interact
Just a quick question. Does any of you know of a good plugin to

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.