• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

str_replace or preg_replace random number from string

phppreg-replacestr-replace


PHP Snippet 1:

$id = $_GET["id"]

PHP Snippet 2:

$url = "http://anyurl/index.php?id=".$id."&abc=any"

PHP Snippet 3:

<?php
$string = 'http://anyurl/index.php?id=4876&abc=any';
$new_string = preg_replace('/[0-9]+/', $_GET["id"], $string);
echo $new_string;
// Will display http://anyurl/index.php?id=3345&abc=any 
?>

Related Snippets

MySQL default time format UTC or GMT?

Mobile browsers are adding .html to filename on download

Laravel dosen't connect with Oracle

Laravel 5: Is there a non-case sensitive way to sort a collection by an attribute?

Issue with laravel eloquent model property

Changing font color in javascript

Laravel 8: Array to string conversion while calling route:list

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

Laravel Excel::store file empty after stored

How to get the ID of the link in another page in php

WHERE IN array binding in DB::raw laravel 5.4

javascript html popup window

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

How to give apache permission to write to home directory?

how to youtube api data to print in toolset metabox using a button click before save-post

About Contact Privacy policy Terms and conditions