New to our community ?

Discover a world of possibilities! Join us and explore a vibrant community where ideas flourish and connections thrive.

One of Our Valued Members

Thank you for being part of our community. Your presence enriches our shared experiences. Let's continue this journey together!

Home Blog Page 10

Converting words to numbers in PHP

0

Welcome back to shorltearner.com, we are starting a new series of PHP interview questions for beginners and experienced,so in previous post we learn, Write a PHP program to check if the bits of the two given positions of a number are same or not
In this post we see how to Converting words to numbers in PHP.
Also Read
Unable to create a directory a wordpress error
PHP program that multiplies corresponding elements of two given lists
PHP program to print out the multiplication table up to 6*6

convert number to words in php
<?php
function word_digit($word) {
    $warr = explode(';',$word);
    $result = '';
    foreach($warr as $value){
        switch(trim($value)){
            case 'zero':
                $result .= '0';
                break;
            case 'one':
                $result .= '1';
                break;
            case 'two':
                $result .= '2';
                break;
            case 'three':
                $result .= '3';
                break;
            case 'four':
                $result .= '4';
                break;
            case 'five':
                $result .= '5';
                break;
            case 'six':
                $result .= '6';
                break;
            case 'seven':
                $result .= '7';
                break;
            case 'eight':
                $result .= '8';
                break;
            case 'nine':
                $result .= '9';
                break;    
        }
    }
    return $result;
}

echo word_digit("zero;three;five;six;eight;one")."\n";
echo word_digit("seven;zero;one")."\n";
?>
035681 701

check the bits of the two given positions of a number are same or not

0

Welcome back to shorltearner.com, we are starting a new series of PHP interview questions for beginners and experienced,so in previous post we learn, Write a PHP program to print out the multiplication table upto 6*6
In this post we Write a PHP program to check if the bits of the two given positions of a number are same or not.

mysql interview questions

Also Read :
PHP Login Script With Remember me.
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript
Check Email is Already Registered in Database using Ajax and JavaScript.
How to hide extension of html and php file.?
PHP program that multiplies corresponding elements of two given lists

<?php
function test_bit_position($num, $pos1, $pos2) {
   $pos1--;
   $pos2--;
   $bin_num = strrev(decbin($num));
   if ($bin_num[$pos1] == $bin_num[$pos2]) {
     return "true";
   } else {
     return "false";
   }
}
echo test_bit_position(112,5,6)."\n";
?>

PHP program to print out the multiplication table up to 6*6

0

Welcome back to shorltearner.com, we are starting a new series of PHP interview questions for beginners and experienced,so in previous post we learn, how to Write a PHP program that multiplies corresponding elements of two given lists.
In this post we Write a PHP program to print out the multiplication table upto 6*6.

php session interview questions

Also Read :
PHP Login Script With Remember me.
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript
Check Email is Already Registered in Database using Ajax and JavaScript.
How to hide extension of html and php file.?

<?php
for ($i = 1; $i < 7; $i++) {
  for ($j = 1; $j < 7; $j++) {
     if ($j == 1) {
       echo str_pad($i*$j, 2, " ", STR_PAD_LEFT);
     } else {
       echo str_pad($i*$j, 4, " ", STR_PAD_LEFT);
     }
  }
  echo "\n";
}
?>

Output

1 2 3 4 5 6 2 4 6 8 10 12 3 6 9 12 15 18 4 8 12 16 20 24 5 10 15 20 25 30 6 12 18 24 30 36

multiplies corresponding elements of two given lists.

0

Welcome back to shorltearner.com, we are starting a new series of PHP interview questions for beginners and experienced,so in this post we will see, how to Write a PHP program that multiplies corresponding elements of two given lists.

advanced php interview questions

Also Read :
PHP Login Script With Remember me.
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript
Check Email is Already Registered in Database using Ajax and JavaScript.
How to hide extension of html and php file.?

<?php
function multiply_two_lists($x, $y)
 {
    $a = explode(' ',trim($x));
    $b = explode(' ',trim($y));
    foreach($a as $key=>$value) 
 {
        $output[$key] = $a[$key]*$b[$key];
  }
    return implode(' ',$output);
 }
echo multiply_two_lists(("10 12 3"), ("1 3 3"))."\n";
?>

Output

10 36 9

how to delete a file with the help of PHP

0

Welcome back to shortlearner.com, in this post we will see how to delete a file inside the directorywith the help of PHP.

delete a file using php

so its quite easy to delete the files inside the directory with the help of a single predefined PHP function. PHP provide us a predefined function unlink.
with the help of this function we can easily delete the files from our directoryso in the below example we should try to learn how the unlink function works.

Also Read :
Get Domain name from URL
How to Send Attachment on mail using PHP.
PHP Login Script With Remember me.
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript
Check Email is Already Registered in Database using Ajax and JavaScript.
How to hide extension of html and php file.?


so here i am creating a variable $file_pointer , in the value of this variable we put the file name which we want to delete from our directory,

so in the below example i want to delete myfile.php from my directory so i put this inside the value of variable.

and put this variable as a parameter into unlink function
. whenever i run this file, the unlink function works and delete the myfile.php file from my directory.