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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:10:31+00:00 2026-05-27T02:10:31+00:00

I am currently building breadcrumb. It works for example for http://localhost/researchportal/proposal/ <?php $url_comp =

  • 0

I am currently building breadcrumb. It works for example for

http://localhost/researchportal/proposal/

    <?php
            $url_comp = explode('/',substr($url,1,-1));
            $end = count($url_comp);        
            print_r($url_comp);
            foreach($url_comp as $breadcrumb) {                     
            $landing="http://localhost/";
            $surl .= $breadcrumb.'/';                               
                if(--$end)
                 echo '
                 <a href='.$landing.''.$surl.'>'.$breadcrumb.'</a>&raquo;';
                else
                 echo '
                 <a href='.$landing.''.$surl.' class="active">'.$breadcrumb.'</a>';
                };?>

But when I typed in http://localhost////researchportal////proposal//////////

All the formatting was gone as it confuses my code.

I need to have the site path in an array like ([1]->researchportal, [2]->proposal)
regardless of how many slashes I put.

So can $url_comp = explode('/',substr($url,1,-1)); be turned into a regular expression to get my desired output?

  • 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-27T02:10:32+00:00Added an answer on May 27, 2026 at 2:10 am

    You don’t need regex. Look at htmlentities() and stripslashes() in the PHP manual. A regex will return a boolean value of whatever it says, and won’t really help you achieve what you are trying to do. All the regex can let you do is say if the string matches the regex do something. If you put in a regex requiring at least 2 characters between each slash, then any time anyone puts more than one consecutive slash in there, the if statement will stop.

    https://www.php.net/manual/en/function.stripslashes.php

    https://www.php.net/manual/en/function.htmlentities.php

    Found this on the php manual.

    It uses simple str_replace statements, modifying this should achieve exactly what your post was asking.

        <?
        function stripslashes2($string) {
            $string = str_replace("\\\"", "\"", $string);
            $string = str_replace("\\'", "'", $string);
            $string = str_replace("\\\\", "\\", $string);
            return $string;
        }
        ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently building a Java app that could end up being run on many
i wonder if you could help me building a little breadcrumb path with php.
Im currently building a php framework... again. I have a class called config. its
I'm currently building my first database in MySQL with an interface written in PHP
I am currently building an application in PHP using CodeIgniter. Usually, in .NET applications,
I am currently building a PHP framework (original, i know) and im working on
I am currently building in Version 3.5 of the .Net framework and I have
I am currently building an internal web application used in a factory/warehouse type location.
We're currently building an application that executes a number of external tools. We often
I'm currently building a small web application that includes a fair amount of JavaScript.

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.