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
PHP Web Logs (BLogs)
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
Submit Site
Forex Trading Online forex trading platform

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 : 5760
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;
}
?>



PHP5 URL Object
Categories : PHP, PHP Classes, URLs, Strings
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
Avoiding or Detecting high bit characters in a string. Useful when you want to create a valid RSS feed
Categories : PHP, Strings, Unicode, Regexps, Rich Site Summary (RSS)
Allows you to parse a deliniated string and put the individual fields in a SELECT option in a form
Categories : HTML, PHP, Strings
Using data from a string.
Categories : PHP, Strings, CURL
IPhider Obscure Any URL Anonymity connection lores obfuscation corporate survival.
Categories : PHP, Algorithms, Security, URLs
function textwrap will wrap text to any desired width using <BR>\n as the default line break. Default wrap width is 80 columns.
Categories : Strings, HTML and PHP, PHP
Adding dashes to credit card numbers
Categories : Strings, Credit Cards, PHP
getting the name of the current script and query string
Categories : PHP, Global Variables, Variables, URLs
PHP Script to find url links in a page
Categories : PHP, URLs, Regexps, Arrays
I need a trim function/regexp that will trim all " " from the ends of a string.
Categories : Regexps, PHP, Strings
mysql_escape_string
Categories : PHP, MySQL, Databases, Strings
php jump urls...the best way
Categories : PHP, URLs, Filesystem
Look for the *position* of the first occurence of string2 in string1, beginning at position start.
Categories : Complete Programs, PHP, Strings
The Porter Word Stemming Algorithm in PHP Reduces words to their base stem for search engines and indexing
Categories : Algorithms, PHP, Strings
 Patrick Mueller wrote :270
wouldn`t it be easier to just use a ereg_replace-function ???