Skip to main content

Posts

Showing posts from February, 2019

Sort the array of characters in the array: PHP

If you want to select an array in the array to retrieve data from a particular variable and sorted you can use the following as an example: <?php $f = array(             array('Name' =>'Ucup',                    'Class' => 7),             array('Name' => 'Faizal',                   'Class' => 9),             array('Name' => 'Abdul',                   'Class' => 8)             ); function sort($r,$d) {     return strnatcmp($r['Name'],$d['Name']); } usort($f,'sort'); foreach($f as $k=>$v) {      echo $v['Name']; } ?> On the listing coding above are arrays in the array contains variables and class name with a certain value, the first array contains the name of the class ucup and 7, both faizal and 9th grade, third grade 8. The name Abdul  function sequence {return strnatcmp};  // useful to sort the array of characters in the array ($ r $ d);  foreac

Creating a pyramid shape: PHP

To create a pyramid we need 3 repetitions for example as follows: <?php //PYRAMID TOP for ($i = 0; $i < 5; $i++) {  for ($j = 5; $j > $i; $j--) {  echo '&nbsp';  }  for ($k = 0; $k <= $i; $k++) {  echo '*';  }  echo '<br/>';  } //PYRAMID BOTOM  echo "<br/><br/>";  for ($i = 1; $i <= 5; $i++) {     for ($j = 6; $j > $i; $j--) {         echo '*';     }      for ($k = 2; $k <= $i; $k++) {      echo '';      }  echo '<br/>';  } ?> for ($ i); // repetition i to make the number of rows repetition of 0 to no more than 5, i ++ grow 0-4, echo '<br/>', // to act line  for ($ j); // repetitions to create a column j j 5 worth no more than i (0), 5-0 j-- reduced, echo '& nbsp' // to display a blank character  for ($ k); // repetitions k to fill column 0 as i no more and grow, echo '*'; // to produce a character *  The result: If you have any ques

Creating a series of numbers and multiples "dangdingdong": PHP

Here I want to share my experience at that time I was working as a programmer php test and given the matter as follows: Make a 1-100 number series and each multiple of three figures were changed "ding", each multiple 5 change "dong", and any change multiple 3 & 5 "dingdong". and here's the answer: <?php for($i=1; $i<=100; $i++){ if($i%3==0 && $i%5==0){ echo "dingdong"; } else if($i%3==0){ echo "ding"; } else if($i%5==0){ echo "dong"; } else{ echo $i; } } ?> for ($ i = 1; $ i <= 100; $ i ++);  // useful to make a sequence of numbers 1-100  if ($ i% 3 == 0);  // mean if i (1) multiple (%) 3 echo "ding" will feature characters ding //  if ($ i% 5 == 0);  // mean if i (1) multiple (%) 5, echo "dong" will display the character dong //  if ($ i% 3 == 0 && $ i% 5 == 0);  // mean if i (1) multiple (%) 3 & 5, echo "dingdong" dingdong character //

Checking Prime Numbers: PHP

To know the number is prime or not using the programming language PHP, we can use the following method: <?php $n = 4; // please enter the value of N here $status = "PRIME"; for ($i = 2; $i <= $n-1; $i++) { if ($n % $i == 0)  { $status = "NO PRIME"; break; } } echo "Number ".$n." is : ".$status; ?> $ n = 4;  // here you are free to determine what the value or number you want to check, here I am trying to check the status of number 4. if prime prime prime not otherwise status.  the result:  4 is not a prime number   is now $n I change into 2  results: 2 is a prime number If you have any questions please comment.  Do not forget to like and share.  Learn Programming in  fajaryusuf . com  wrote.  :) 

PHP: Introduction Operator

Table of arithmetic operators Sample Script  aritmatika.php <? php  $ value1 = 32;  $ value2 = 8;  $ number = $ value1 + $ value2;  $ less = $ nilai1- $ value2;  $ time = $ value1 * $ value2;  $ to = $ value1 / $ value2;  $ remainder = $ value1% $ value2;  print "Reviews Arithmetic operation Example";  print "The value \ $ value1 = $ value1 and \ $ value2 = $ nilai2 <br>";  print "\ $ value1 + \ $ value2 = $ amount most";  print "\ $ value1 - \ $ value2 = $ less than most";  print "\ $ value1 * \ $ value2 = $ times the most";  print "\ $ value1 / \ $ value2 = $ for most";  print "\ $ value1% \ $ value2 = $ leftovers most";  ?> The result: Know the assigment operator The following table of symbols and Functions of the assignment operator used Example Scripts  assignment.php <?php $data1=10; $data1+=2; print "Nilai \$data1 adalah $data1 <br><br>"; $dat

PHP: Data Types and Variables

Variable is a very important thing in a programming language.  Since most of the programming process is to process the data stored in the variable. variable name There are some rules that need to be considered in making a variable in PHP is: Each variable is always preceded by a $ (dollar) Allowed three types of characters are letters, numbers and underscores The first character must be a letter or underscore If a variable name is two, there should be no spaces in between. Small and large letters will be different (  case sensitive  ) Giving value to the variable To assign a value to a variable, you can follow the formula as follows: $variable_name = value of the data; example: <?php $value1=12; //type data integer $value2=8.99; //type data float atau double $value3="Tes Nilai variabel string"; //type data string print "Tipe data integer : $value1<br>"; print "Tipe data double : $value2<br>"; print "Tipe data st