WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Remove URL Parameter Substr Strstr
Categories : PHP, URLs, Strings Click here to Update Your Picture
Ulysses Ludwig
Date : Mar 06th 2000
Grade : 1 of 5 (graded 1 times)
Viewed : 9477
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Ulysses Ludwig
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?php

/*
Name: RemoveUrlParam.php3
AUTHOR: Ulysses J Ludwig
AUTHOR URL: www.ujludwig.com
DATE CREATED: 1.24.00
LAST MODIFIED: 3.06.00 (6:30 PM)
INCLUDED BY: Lib.inc
CALLED BY: Anywhere
PREREQUISITES: None
COMMENTS: The script removes a url parameter from a url string. Please
note: I am sure there is a way to shorten this script, but then no one
would be able to read it but me. Ergo it is longer for a reason. Also,
if the url passed in is already encoded, then the parameter should also
be encoded first
EXAMPLE: Fn_remove_url_param("$Url&ParamVariable","param_name");
*/
/////////////////////////////////////////////////////////////////////////////////////////
////////////        (REMOVE URL PARAMETER) CALLED FROM ANYWHERE /////////////////////////////
function Fn_remove_url_param($In_url, $In_param_name)
{
                trim($In_url);
                $qm = chr(63);                                                         //
Creates a question mark
                $L_qm_pos = strpos($In_url, $qm) + 1;         // Creates a variable that holds the
position of the question mark (it may be 0 if there is no question mark)
                // When searching for the parameter, make sure that it is
                // proceeded by an & or ? and followed by an = sign
                $L_search_string = ("?" . $In_param_name . "=");
                $L_param_pos = strpos($In_url,$L_search_string);
                if (!empty($L_param_pos))
                {
                        // Parameter is led by ?... preserve the question mark
                        $L_param_pos++;
                }
                else
                {
                        $L_search_string = ("&" . $In_param_name . "=");
                        $L_param_pos = strpos($In_url, $L_search_string);        
                }

                if (!empty($L_param_pos))
                {
                        // The parameter exists in the param string so remove it
                        // Find the end of the param name value pair
                        for ($i = $L_param_pos + 1; $i <= strlen($In_url); $i++)
                        {
                                $L_character = (substr($In_url, $i, 1));
                                if ($L_character == " " or $L_character == "&")
                                {
                                        $i ++;
                                        break;
                                }
                        }
                                
                        $In_url = substr($In_url, 0,$L_param_pos) .
                                substr($In_url, $i - 1, strlen($In_url));
                }
        return Fn_repair_url($In_url); // Return the page
}

////////////////////////////////////////////////////////////////////////////////////
//////////// Repair URL ////////////////////////////////////////////////////////
function Fn_repair_url($In_url)
{

        $L_pos = strpos($In_url, "?&");
        if (!empty($L_pos))
        {
                // Remvove the &
                $In_url = substr($In_url, 0,$L_pos + 1) .
                        substr($In_url, $L_pos + 2, strlen($In_url));        
        }
        
        $L_pos = strpos($In_url, "&&");
        if (!empty($L_pos))
        {
                // Remove one of the &s
                $In_url = substr($In_url, 0,$L_pos + 1) .
                        substr($In_url, $L_pos + 2, strlen($In_url));        
        }
        
        if (strpos($In_url, "?") > 0 and (strpos($In_url, "?") == strlen($L_url)))
        {
                // Then the question mark that is trailing has no parameters, remove it
                $In_url = substr($In_url, 0, strlen($L_url - 1));
        }
        
        return $In_url;
}
?>



pick up an array of variables from a query string such as: http://www.archipro.com/test.php?state=AB&state=BC
Categories : PHP, Strings, URLs, Global Variables
PHP5 URL Object
Categories : PHP, PHP Classes, URLs, Strings
Customizable encoding and decoding strings with security.
Categories : PHP, Strings, HTML and PHP
SubmitForce URL power submitter (searchengine submission class)
Categories : PHP, Search Engines, URLs, PHP Classes
I need a trim function/regexp that will trim all " " from the ends of a string.
Categories : Regexps, PHP, Strings
textwrap fill-paragraph (justification)
Categories : Strings, PHP, Algorithms
Parse string to find sub-string between two arbitrary strings
Categories : PHP, Strings, HTML and PHP, Arrays
Read a file with strings and create a new file with the first half of each string
Categories : PHP, Strings, Filesystem
Finding numbers within a string
Categories : PHP, Regexps, Strings
How to Get a character array from a string
Categories : PHP, Strings, Arrays
Takes an array and returns a string, suitable for inputing in an SQL statement
Categories : Arrays, Strings, PHP
What is the best way to split a string that consists of two bits of data seperated by whitespace?
Categories : Regexps, Strings, PHP
Printer friendly pages from anywhere on a website.
Categories : PHP, Strings, Content Management
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
mysql_escape_string
Categories : PHP, MySQL, Databases, Strings
 Patrick Mueller wrote :270
wouldn`t it be easier to just use a ereg_replace-function ???