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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:24:02+00:00 2026-06-04T18:24:02+00:00

I have the follow code, which get $_GET and make division by controller, action

  • 0

I have the follow code, which get $_GET and make division by controller, action and params

http://localhost/controller/action/param1/param2

$url = explode('/', $_GET['url']);
$urlSize = count($url);
$filter = $this->factory('Core\Security\Filter');

if($urlSize >= 1) {
    $controller = $filter->replace($url[0], 'friendly-url');

    if($urlSize >= 2) {
        $action = $filter->replace($url[1], 'friendly-url');

        if($urlSize >= 3) {
            unset($url[0], $url[1]);

            foreach($url as $index => $param) {
                $params[] = $filter->replace($param, 'friendly-url');
            }
        }
    }
}

Core\Security\Filter->replace() which I am developing right now:

public function replace($data = null, $type = 'alphanumeric') {
    /*
        @TODO, implement regex by type

        numeric
                $regex = '/^[[:digit:]]$/';
        alphanumeric
                $regex = '/^[[:alnum:]]$/';
        friendly-url
                $regex = '/[^a-zA-Z0-9_-]+/';
                $replace = '-'
        username
                $regex = '/^[^a-zA-Z0-9_-.]{3,32}+';
        email
                $regex = '/^[[a-zA-Z0-9_-.]{1,96}]+@[a-zA-Z0-9-]{2,64}+(?:\.[a-zA-Z0-9-]+)*$/';
    */
}

Ok, the problem I have is: How to get urls with this format:

http://localhost/controller/action/param1/param2:value2

$param array:

Array(
    [0] => param1
    [1] => Array(
       [param2] => value2
    )
)

SOLVED WITH THIS:

foreach($url as $index => $param) {
    if(strstr($param, ':')) {
        $subParam = explode(':', $param, 2);
        $this->_request['params'][][$subParam[0]] = $filter->replace($subParam[1], 'friendly-url-param');
    } else {
        $this->_request['params'][] = $filter->replace($param, 'friendly-url-param');
    }
}
  • 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-04T18:24:05+00:00Added an answer on June 4, 2026 at 6:24 pm
    <?php
    
    $url = 'http://localhost/controller/action/param1/param2:value2';
    
    $parts = parse_url($url);
    $path = $parts['path'];
    
    list($controller, $action, $params) = explode('/', ltrim($path, '/'), 3);
    
    function parse_params($params) {
        $parsed_params = array();
        $path_segments = explode('/', $params);
        foreach ($path_segments as $path_segment) {
            if (strstr($path_segment, ':')) {
                list($k, $v) = explode(':', $path_segment, 2);
                $parsed_params[] = array($k => $v);
            } else {
                $parsed_params[] = $path_segment;
            }
        }
        return $parsed_params;
    }
    
    
    
    $params = parse_params($params);
    
    print_r($params);
    

    OUTPUT

    Array
    (
        [0] => param1
        [1] => Array
            (
                [param2] => value2
            )
    
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which reads in the follow file, append a \r\n
i have the follow code: searchResults.SearchResultCollection.Add( new SearchResult() { Header = HttpUtility.HtmlDecode( htmlDocument.DocumentNode .SelectSingleNode(initialXPath
So... is strange, I have the follow code in my Window control for setting
Follow up to this question . I have the following code: string[] names =
I have code as follows: $(#item_select).change(function() { var params = $(#item_select option:selected).val(); $.post('/account/ar_form.php', {idata:
Code snippet to follow. I have a struct (example code has class, tried both,
I have the following code which i m trying to compile: #include <boost/filesystem/convenience.hpp> #include
I want to add code to my iOS app which prompts users to follow
I have the following C++ code that I'm trying to get to compile (relevant
I have the following php code (getRout.php).. which response results in xml formats ...

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.