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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:20:30+00:00 2026-06-16T09:20:30+00:00

I am trying to parse a string but what I get returned is incorrect

  • 0

I am trying to parse a string but what I get returned is incorrect , I am trying to extract just the question mark from doc=? and slide=?, but instead I get

doc id:&doc=9729&slide=214679&#doc=9729&slide=21

slide id:&slide=214679&#doc=9729

string :

http:/securefinder.com/ajax_query/delimiter.aspx?q=LNG&f=1.1&doc=9729&slide=214679&#doc=9729&slide=214679&

It seems it does not accept & as the delimiting character.

 <?php

    function from_to($string, $from, $to) {
        //Calculate where each substring is found inside of $string
        $pos_from = strpos($string, $from);
        $pos_to   = strpos($string, $to);


        //The function will break if $to appears before $from, throw an exception.
        if ($pos_from > $pos_to) {

        }

        return substr(
            $string,
            $pos_from, //From where the $from starts (first character of $from)
            $pos_to - $pos_from + strlen($to) //To where the $to ends. (last character of $to)
        );
    }

    $str = "http:/securefinder.com/ajax_query/delimiter.aspx?q=LNG&f=1.1&doc=9729&slide=214679&#doc=9729&slide=214679&";


         $doc_id = from_to($str, 'doc=', '&');
          $slide_id = from_to($str, 'slide=', '&');


echo 'doc id:' . $doc_id ;
echo 'slide id:'. $slide_id;



    ?>
  • 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-16T09:20:31+00:00Added an answer on June 16, 2026 at 9:20 am

    Consider using prase_url() to break up the url and then use parse_str() on the query result to first break up your query by #, the results of that by &, and finally the results of that by =.

    This way you don’t need to write your own parsing logic. From this you will get a nice array to manipulate instead of trying to figure out how to manipulate your string.

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

Sidebar

Related Questions

Trying to parse time from string, but get this error. Tried few formatting string.
I'm trying to parse the xml document returned from this link but I get
I am trying to parse the JSON results from an AJAX call, but do
I'm trying to parse a String that represents a date using GMT, but it
i'm trying to parse the response i get from a http get request in
I´m trying to parse a String to a Decimal but I keep getting a
I am trying to parse the following string and get the result. string test
I'm using ruby and trying to get a value from a string that I
I'm trying to parse a string from a mess (SOME.String_With-bits.txt) into a clean string
I am trying to parse a string and get another string in the middle.

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.