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

  • SEARCH
  • Home
  • 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 643429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:16:54+00:00 2026-05-13T21:16:54+00:00

Please help me out on this explode() function issue. I am getting unexpected results

  • 0

Please help me out on this explode() function issue. I am getting unexpected results for the third scenario, what’s the explanation?

EDIT: The value $page_string is actually from the database. This time I did the tests using var_dump instead of echo. The strings, How does php count them? How is “15&page” count 11?

var_dump($page_string);//string(11) "15&page"

1. Pop out ampersand … fine.

    $page_id_array = explode("&",$page_string);
    $page_id = $page_id_array[0]; 
    var_dump($page_id); 
    // string(2) "15"

2. Pop out number … fine

    $page_id_array = explode("15",$page_string);
    $page_id = $page_id_array[1]; 
    var_dump($page_id); 
    //string(9) "&blog"

3. Pop out ‘&page’ … why?

     $page_id_array = explode("&page",$page_string);
     $page_id = $page_id_array[0]; 
     var_dump($page_id); 
     //string(11) "15&page"
     var_dump($page_id_array[1]);
     //NULL

EDIT: After answer and comments from jasonbar I did the test which confirms his answer:

     $page_id_array = explode("&page",$page_string);
     $page_id = $page_id_array[0]; 
     var_dump($page_id); 
     //string(2) "15"
  • 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-13T21:16:54+00:00Added an answer on May 13, 2026 at 9:16 pm

    I think my comment seems a likely explanation. I tried out your code using “15&page” as the test string and it explodes properly using ‘&page’ as the delimiter.

    Make sure the & isn’t actually encoded as &

    You could try print_r’ing the array you get back from explode() to see if thats really the case. If so you would end up with 15, amp;page when exploding on just ‘&’.

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

Sidebar

Ask A Question

Stats

  • Questions 512k
  • Answers 512k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes it is possible. See this examples (in Russian, sorry)… May 16, 2026 at 5:39 pm
  • Editorial Team
    Editorial Team added an answer Only transfer the data you need - use lazy loading… May 16, 2026 at 5:39 pm
  • Editorial Team
    Editorial Team added an answer someclass instance at 0xdeadbeef is the result of the the… May 16, 2026 at 5:39 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

This is script what I have currently - <script type=text/javascript> $(document).ready(function () { $('.RemoveSystem').click(function
i really really need your help. I'm successfully setting up a connection to my
Can someone please clarify using a SIMPLE user story the full slice of what
I have read O'Reilly book, in that I came to know this get-put principle
I am faced with an issue in Ruby on Rails. I am looking to
I'm having this problem with UTF8 string comparison which I really have no idea
This is probably something simple but it's driving me nuts. I'm making some pagination
I have a MySQL database that looks similar to this: ID Group Name 1
Using PHP.. Here is what I have.. I'm gonna explain the whole thing and
A rat is placed in a maze at some unknown position in the maze.

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.