how to use Implode() and Explode() in php

Implode() Function
The implode function is used to "join elements of an array with a string".
Syntax
implode (separator , array);

Example 1

<
body bgcolor="pink">
<
h3>Implode Function</h3>
$arr=
array ('Developer','Global','Desk');
echo 
implode(" ",$arr);
?>
</
body>


Example 2


<
body bgcolor="pink">
<
h3>Implode Function</h3>
$arr = 
array ('Developer','Global','Desk');
$space_separated = implode(
" ", $arr);
$comma_separated = implode(
" , ", $arr);
$slash_separated = implode(
" / ", $arr);
$dot_separated = implode(
" . ", $arr);
$hyphen_separated = implode(
" - ", $arr);
echo 
$space_separated.'
'
;
echo 
$comma_separated.'
'
;
echo 
$slash_separated.'
'
;
echo 
$dot_separated.'
'
;
echo 
$hyphen_separated;
?>
 
</
body>




Explode() Function
The explode function is used to "Split a string by a specified string into pieces i.e. it breaks a string into an array".

Syntax
explode (separator,string,limit);
  
Example1


<
body bgcolor="pink">
<
h3>Explode Function</h3>
$str=
"Developer Global Desk";
print_r(explode(
" ",$str));
?>
</
body>




how to set session security in php

Description :
Timing-out sessions is a very important action if you are dealing with users logged in to your website or application. If a user logs in to your site in an Internet café and then leaves the computer and café without logging out, how do you stop the next user on that computer from still having access to the previous user’s session? Well you can use the following code:
session_start();
// set time-out period (in seconds)
$inactive = 600;
 
// check to see if $_SESSION["timeout"] is set
if (isset($_SESSION["timeout"])) {
    // calculate the session's "time to live"
    $sessionTTL = time() - $_SESSION["timeout"];
    if ($sessionTTL > $inactive) {
        session_destroy();
        header("Location: /logout.php");
    }
}

$_SESSION["timeout"] = time();

php array functions

Function
Description
Create an array
Changes all keys in an array
Split an array into chunks
Creates an array by using one array for keys and another for its values
Counts all the values of an array
Exchanges all keys with their associated values in an array
Return all the keys or a subset of the keys of an array
Merge one or more arrays
Sort multiple or multi-dimensional arrays
Pad array to the specified length with a value
Calculate the product of values in an array
Pick one or more random entries out of an array
Return an array with elements in reverse order
Searches the array for a given value and returns the corresponding key if successful
Extract a slice of the array
Remove a portion of the array and replace it with something else
Calculate the sum of values in an array
Removes duplicate values from an array
Sort an array in reverse order and maintain index association
Sort an array and maintain index association
Create array containing variables and their values
Count all elements in an array, or properties in an object
Return the current element in an array
Return the current key and value pair from an array and advance the array cursor
Set the internal pointer of an array to its last element
Checks if a value exists in an array
Checks if a variable is an array
Fetch a key from an array
Sort an array by key in reverse order
Sort an array by key
Assign variables as if they were an array
Sort an array using a case insensitive "natural order" algorithm
Sort an array using a "natural order" algorithm
Advance the internal array pointer of an array
Rewind the internal array pointer
Create an array containing a range of elements
Set the internal pointer of an array to its first element
Sort an array in reverse order
Shuffle an array
Alias of count
Sort an array

difference between convert.tostring() and .tostring() in c#

Introduction:

In asp.net, there are different ways to convert value type to string like convert.tostring() and .tostring().

If you declare a string variable and don't assign any value in C#. Then by default it take a blank or null value itself . in this case if u use .ToString() method then our program should throw null reference exception. and in Convert.ToString() our program doesn't throw any exception. bcoz by default it takes a blank value instead of null.

For example:

          string myVar = "" ;

          myVar = null;
          Console.Write(abc.ToString());

This unhandled exception thrown by NullReference.


          Console.Write(Convert.ToString(abc));


This takes a blank value instead of null.