-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspotify.php
More file actions
40 lines (29 loc) · 741 Bytes
/
spotify.php
File metadata and controls
40 lines (29 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* A php answer to the spotify question.
*
* The Question:
* https://www.spotify.com/uk/jobs/tech/reversed-binary/
*
* The answer:
* https://github.com/adulion/spotify_binary_answer
*
* Note:
* The answer can not be written in php and has to run from the
* Command line but this just shows a simple way to achieve
* An answer in php
*
* chris[at]justni[dot].com
*
*/
if(!empty($_POST)){
$sample_num = (int) $_POST['sample_input'];
$binary_num = decbin($sample_num);
$reversed_binary_num = strrev($binary_num);
echo bindec($reversed_binary_num);
}
?>
<form target="<?=$_SERVER['PHP_SELF'];?>" method="POST">
<input type="text" name="sample_input"><br />
<input type="submit">
</form>