How to Remove %20 from Url [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
http://oktrad.dotdigital.pk/t/Alemán%20(Alemania)-Alemán%20(Austria)
basically i want to remove %20 from url. There no any Query parameter in url. i want remove %20 to underscore '_' or same as space.
http://oktrad.dotdigital.pk/t/Alemán (Alemania)-Alemán (Austria)
http://oktrad.dotdigital.pk/t/Alemán_(Alemania)-Alemán_(Austria)

You can use urldecode() :
urldecode('http://oktrad.dotdigital.pk/t/Alemán%20(Alemania)-Alemán%20(Austria)')
//output - http://oktrad.dotdigital.pk/t/Alemán (Alemania)-Alemán (Austria)
Or, you can use str_replace() for convert space to _ :
str_replace('%20', '_', 'http://oktrad.dotdigital.pk/t/Alemán%20(Alemania)-Alemán%20(Austria)')
//output - http://oktrad.dotdigital.pk/t/Alemán_(Alemania)-Alemán_(Austria)

Related

REGEX for alternate characters in PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a string mystring. I have to replace the alternate characters with x so that final output is mxsxrxnx. All the alternate characters starting from 2nd position are replaced with x. I can do it with loop but is there a Regular expression for that or a better way in PHP? Please help.
Using a reset match meta-character \K you are able to do it:
.\K.
Live demo
PHP:
echo preg_replace('/.\K./', 'x', 'mystring'); // mxsxrxnx

preg match extract digits from string after pattern [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a string of the form
<something>_string_t_<digits>
How can I extract just the <digits> portion in PHP ? I need to detect the string_t first and then pull out the digits.
You want something like this:
$captures;
preg_match('/string_t_(\d+)/', $string, $captures);
do_something($captures[1]);
$captures[1] will contain <digits> (assuming <digits> is composed entirely of numbers - if it's not, use the more general (.+) in place of (\d+)).

Add "+" in place of space in php [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I would like to add + sign where ever I find space in string.
I have something like
$str = "How are you.? I'm fine."
should be
$C_str = "How+are+you.?+I'm+fine."
How I can do this in php.?
Any better idea.?
If there is just single space between chars use
$C_str = str_replace(' ','+',$str);
or if there can be more that just space like tab,etc then use this one
$C_str = preg_replace( '/\s+/','+', $str);

preg_match pattern with signal character [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I need a pattern which is able to find a word wrapped in two signal characters.
Basically something like
$string = "bablabla __test__ blablabla"
preg_match("/__\w__/", $string, $result);
print_r($result);
\w is a single word character. It would match __t__ but not multiple characters like __test__. Try \w+

Regex Replace pattern [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need the regular expression to replace using following rule:
Any integer present before . then no take place.
If no integer present before . then that should be replace.
$input = (contain anything characters, symbols, numbers, floats etc)
Example:
$myString = "Example 1.58 Stack.68";
Output should be
Example 1.58 Stack,68
preg_replace('#(?<!\d)\.#',',',$myString)

Categories