Header menu

_________________________________________________________________________________

Thursday 19 December 2013

Explain difference between array_merge( ) and array_combine( ) in php

ARRAY_MERGE()


array_merge() id used to merge the elements of one or more than one array in such a way  that the value of one array appends at the end of first array. If the any of the arrays have same key ,then the later value overrides the previous value for that key. The output of the function is one resultant array and this function takes two arrays as input.

ARRAY_COMBINE()


array_combine() is used to creates a new array by using the key of one array as keys and using the value of other array as values.One thing to keep in mind while using array_combine() that number of values in both arrays must be same.

Example :

<h2>ARRAY_MERGE()</h2>
<?php
$array1 = array("one" => "java","two" => "sql");

Wednesday 18 December 2013

Explain Header() function in php in detail

Header function in php :



<?php header("Location: http://www.codesplanet.blogspot.com/"); ?>

Header function in php is used for redirection to some other page. In simplest form it takes one parameter
the destination url . 

Uses of header() function in php

 

1. The header() function use to sends a raw HTTP header to a client.
2. Use for refresh the page on after given time interval.
3. can be used to send email header content like cc, bcc , reply to etc data and lot more .


What is the Limitation of HEADER()?


In PHP the one and most horrible limitation of HEADER() function is that

Monday 16 December 2013

Create variable at runtime in php

Hey ... Today we are going to create variable at runtime from an array;
I have declared an array named $arr and i am iteration array using foreach loop
and for each element creating a variable using   $$ar .
And at last i am printing the created variables.

<?php
$arr=array("1"=>"abc","2"=>"def");
echo "<pre>";
print_r($arr);
foreach($arr as $ar){
   
    $$ar="success:".$ar;
}
echo $abc;
echo "<br/>";
echo $def;

?>


Run the above example , to understand more ...

Friday 6 December 2013

Knockout js Tutorial

<html>
<head>
<style>
body { font-family: arial; font-size: 14px; }
.liveExample { padding: 1em; background-color: #EEEEDD; border: 1px solid #CCC; max-width: 655px; }
.liveExample input { font-family: Arial; }
.liveExample b { font-weight: bold; }
.liveExample p { margin-top: 0.9em; margin-bottom: 0.9em; }
.liveExample select[multiple] { width: 100%; height: 8em; }
.liveExample h2 { margin-top: 0.4em; font-weight: bold; font-size: 1.2em; }
</style>
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js”></script>
<script type=’text/javascript’ src=’http://knockoutjs.com/downloads/knockout-3.0.0.js’></script>
</head>
<body>
<div class=’liveExample’>
<p>Data bind to text field</p> 
<p>First Message: <strong data-bind=”text: msg1″></strong></p>
<p>Second Message: <strong data-bind=”text: msg2″></strong></p> 
<hr>
<p>Data bind to input field</p> 
<p>First Box: <input data-bind=”attr: {value: msg1}” /></p> 
<p>Second Box: <input data-bind=’attr: {value: msg2}’ /></p> 
</div>
</body>
<script>
function AppViewModeldashboard() {
// Here’s my data model
this.msg1 = “hello”;
this.msg2 = “world”;
}
</script>
<script type=’text/javascript’ >
$(document).ready(function(){
var dashboard = new AppViewModeldashboard();
ko.applyBindings(dashboard);
});
</script> 
</html>