Home Blog Page 18

How to append a string using PHP

0

Welcome Back to Shortlearner.com, today we will see how to append a string with the help of php.

How to append a string using PHP

in the previous tutorial we see  How to Concatenate two or more string in PHP By using Concatenation assignment operator(.=) we can append a string

How to Concatenate two or more string in PHP

0

Welcome back to shortlearner.com, today we will see How to Concatenate two or more string in PHP.

How to Concatenate two or more string in PHP
each and every language has their different way to works with strings, in below example we concatenate two strings using php with the help of concatenation operator(“.”)

there is an another way to append a string in PHP.

Print Numbers from 1 to N without using loop in PHP

0

Welcome back to shortlearner.com, today we will learn how to print 1 to N number without using any type of loop.
In this tutorial we print 1 to N number with the help of some php functions like range() and array_walk.
1 to N without using loop in PHP
The range() function is used to create an array of elements of any kind such as integer, alphabets within a given range(from low to high) i.e, list’s first element is considered as low and last one is considered as high.
syntax of range function is like

array range(low, high, step)

It returns an array of elements from low to high.
for example

<?php
$numbers = range(0, 100);
print_r($numbers);
?>

array_walk()
The array_walk() function apply a user defined function to every element of an array. The user-defined function takes array’s values and keys as parameters.

<?php
$array = range(1, 100);
array_walk($array, function ($value) {
echo "$value";
});

?>

and the another way to print 1 to N number is

<?php
print_number(1);
function print_number($number) {
if($number > 100) {
return;
} else {
echo "$number";
echo "<br/>";
print_number(++$number);
}
}
?>

Make a Dynamic Progress Bar using Php.

0
dynamic progress bar data

Welcome back to shortlearner.com
Today we will see how to make a dynamic progress bar,with help the of
bootstrap and php .

dynamic progress bar data
first of all, we should know about where the progress bar is used.
most of the time we see a company or an organisation set there milestone or target and they

Generate Enrollment Number Using PHP.

0

Welcome back to shortlearenr.com ,In today’s post we will see how to generate a school’s teacher unique id with the help of php .
before starting this tutorial first of all we need to know the basic concept of generating an unique id for every teacher.

how to generate enrollment number in php
guys most of the time we see that when we take admission in any university/college they provide us a 12 digit unique code, mostly known as enrollment number.with the help of this unique enrollment number the faculties/staff are able to search all of our information.

so basically our today’s concept is based on this kind of enrollment number of teacher.
we will do some little changes in the process of enrollment number..
we make a enrollment in easy format.
enrollment format : DPS250ASM148
in first 6 digit : DPS(first 3 digit of school code) and 250(last 3 digit of school code).
A (firstname of teacher or staff)
S (if middle name is not enter and designation is staff than it will show S, if middle name is not enter and designation is teacher than it will show T )
M (last name of the teacher or staff)
148 ( and the last 3 digits are random number).

index.php

<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->

<div class="span3">
    <h2>Teacher/Staff Enrollment Processs</h2>
    <form method="post" action="submit.php">
    <label>First Name</label>
    <input type="text" name="teachername" class="span3">
     <label>Middle Name</label>
    <input type="text" name="teachermiddlename" class="span3">
    <label>Last Name</label>
    <input type="text" name="teacherlastname" class="span3">
   
    <label>School Code</label>
    <input type="text" name="schoolcode" class="span3">
   
<label>Designation</label>
<select class="span3" name="designation" >
    <option value="teacher">Teacher</option>
    <option value="staff">Staff</option>
    </select>
    <input type="submit" value="Generate Enrollment Number" class="btn btn-primary pull-right">
    <div class="clearfix"></div>
    </form>
</div>

submit.php

<?php
if(isset($_POST['submit']))
{
    $schoolcode=$_POST['schoolcode'];
    
    $teachername=$_POST['teachername'];
    
    $teachermiddlename=$_POST['teachermiddlename'];
    
    $teacherlastname=$_POST['teacherlastname'];
    
    $designation=$_POST['designation'];
   
    if( $teachermiddlename=="")
    {
        if($designation=="teacher")
        {
           $teachermiddlename="T";  
        }
        else if($designation=="staff")
        {
             $teachermiddlename="S";
        }
    }
    
   
    $idgen="";
    
    $idgen.=$schoolcode[0];
    
    $idgen.=$schoolcode[1];
    
    $idgen.=$schoolcode[2];
    
    $idgen.=$schoolcode[strlen($schoolcode)-3];
    
    $idgen.=$schoolcode[strlen($schoolcode)-2];
    
    $idgen.=$schoolcode[strlen($schoolcode)-1];
    
    $idgen.=$teachername[0];
    
    $idgen.=$teachermiddlename[0];
    
    $idgen.=$teacherlastname[0];
    
    $digits = 3;
    $idgen.=str_pad(rand(0, pow(10, $digits)-1), $digits, '0', STR_PAD_LEFT);
    $idgen=strtoupper($idgen);
    echo $idgen;
    echo "</br>";

}?>