How to use Substr in php [duplicate] - php

This question already has answers here:
How to convert JavaScript code to its PHP equivalent?
(1 answer)
UTF-8 all the way through
(13 answers)
Closed 5 years ago.
I have php code:
$b = 'aHR0cDovL3d3dy5oZHpvZy5jb20vZ2V0X2ZpbGUvМS84Y2Е5МTЕ4ZmМyNmVkNTk0ZmI5Yzc2ZWI2Y2Y2YWVmМС85NDАwМС85NDU4Ny85NDU4Ny5tcDQvP3RpbWU9МjАxNzА5МjYyМDIxNDYmcz05МTUzZmNmYjАyOTUyOWQxY2JhZTВkYzNkY2ZhODVmZiZicj0xODЕ1JmQ9МTcwNyZmPXZpZGVvLm0zdTg~';
echo substr($b,40,1);
But it not print M charater. It show '�' . Why?

Related

PHP issue:Why is there blank output while running this code?And Why is there a 1 in the other case? [duplicate]

This question already has answers here:
PHP printed boolean value is empty, why?
(4 answers)
Why doesn't PHP print TRUE/FALSE? [duplicate]
(3 answers)
Closed 3 years ago.
Using == vs Using !=
/*Testing some basic scenarios in PHP*/
$a=7;
$b=5;
echo $a==$b;
$a=7;
$b=5;
echo $a!=$b;
Output is blank screen in case 1.
Output is 1 in case 2
.Why am I getting these respective outputs?

Why does echo 0.0000001 return an error? [duplicate]

This question already has answers here:
Why is PHP printing my number in scientific notation, when I specified it as .000021?
(7 answers)
Why is MySQL is returning some floats in scientific notation, but not others?
(2 answers)
Closed 5 years ago.
Why does something as simple as this return error ?
echo 0.00000001;
1.0E-8
And this works OK:
echo number_format(0.00000001, 8);
0.00000001

How is strpos() in PHP counting? [duplicate]

This question already has answers here:
Safe to use strpos with UTF-8 strings?
(2 answers)
mb_strpos vs strpos, what's the difference?
(3 answers)
Closed 5 years ago.
I see some strange results with strpos() function...
echo strpos("naše republika", "a"); // 1
echo strpos("naše republika", "š"); // 2
echo strpos("naše republika", "e"); // 4 ???
Can someone explain it to me? Thanks. (php 5.6.30)

date format removing 0 [duplicate]

This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 5 years ago.
How will i remove the 0 in my output i tried this code.
$dates="2017-09-08";
$formated_date=date("d-m-Y", strtotime($dates));
Output:08-09-2017
My Expected Output : 8-9-2017
$dates="2017-09-08";
$formated_date=date("j-n-Y", strtotime($dates));
USE THIS

How to decode Ascii code in a Character in PHP [duplicate]

This question already has answers here:
URL Decoding in PHP
(6 answers)
Closed 6 years ago.
I got the string in this format
solr/?key=color&facet=Blue%26keyword%3Dwoo
However, I want to get it in this format
solr/?key=color&facet=Blue&keyword=woo
Try urldecode:
$url = urldecode("solr/?key=color&facet=Blue%26keyword%3Dwoo");
// = solr/?key=color&facet=Blue&keyword=woo

Categories