A variable variable in PHP Get link Facebook X Pinterest Email Other Apps July 15, 2019 <?php$varname = 'tireqty';$$varname = 100;echo $tireqty; // output: 100?> Get link Facebook X Pinterest Email Other Apps Comments
Timus Problem 1086. Cryptography Accepted Solution in C February 17, 2019 #include <stdio.h> #include <math.h> #include <stdlib.h> int main() { int i, j, k, n, count, square_root, current_number; char is_prime[163842]; int prime_numbers[15001]; square_root = (int)sqrt(163841); // 163841 is the 1500th prime number for(i = 2; i <= 163841; i++) is_prime[i] = '1'; for(i = 2; i <= square_root; i++) { if(is_prime[i] == '1') { current_number = i * i; while(current_number <= 163841) { is_prime[current_number] = '0'; ... Read more
Rolling a dice in PHP March 09, 2019 <?php if(isset($_POST['roll'])) { echo 'You rolled a '.rand(1, 6).'<br/><br/>'; } ?> <form action="index.php" method="post"> <input type="submit" name="roll" value="Roll Dice"/> </form> Read more
Replace every instance of a substring in PHP March 08, 2019 <?php if(isset($_GET['submit'])) { if(strlen($_GET['text']) && strlen($_GET['search_for']) && strlen($_GET['replace_with'])) { $text = $_GET['text']; $search_for = $_GET['search_for']; $replace_with = $_GET['replace_with']; $offset = 0; $search_for_length = strlen($search_for); $replace_with_length = strlen($replace_with); $text = ' '.$text; // that's how search position will never be 0 while($search_for_position = strpos($text, $search_for, $offset)) { $text = substr_replace($text, $replace_with, $se... Read more
Comments
Post a Comment