R4R
Right Place For Right Person TM
R4R PHP FAQS PHP Interview Questions and Answers

 


Totel:94 Click: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

PHP Interview Questions And Answers

Page 1

Questions 1 how can we connect more than one database into  webpage..
Questions 2 PHP means?
uses of PHP?
types of PHP?
explain PHP?

Questions 3 How session will work when we disable cookies of client browser?

Answer
Session is kind of cookie who is work on server side.For working of session on server side cookies should be enable on server side and also on client side browser. But session will also work when cookies are disable on client side by using URL session passing.

Questions 4 How we use array_search() in PHP?

Answer
When we use array_search() function if it found the particular value than it will return index corresponding to array value. Example: <?php $Emp_name_array = array(0 => 'vivek', 1 => 'umang', 2 => 'shrish', 3 => 'jalees'); $key = array_search('umang', $Emp_name_array); // return $key = 1; $key = array_search('vivek', $Emp_name_array); // return $key = 0; ?>

Questions 5 How you differentiate among sort(),assort() and Ksort()?

Answer
1) sort() This function sorts an array. Elements will be arranged from lowest to highest when this function has completed. <?php $fruits = array("lemon", "orange", "banana", "apple"); sort($fruits); foreach ($fruits as $key => $val) { echo "fruits[" . $key . "] = " . $val . "\n"; } ?> ----------------------------OUTPUT--------------------- fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange ------------------------------------------------------- 2) asort() This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. This is used mainly when sorting associative arrays where the actual element order is significant. <?php $fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); asort($fruits); foreach ($fruits as $key => $val) { echo "$key = $val\n"; } ?> --------------------OUTPUT------------------------ c = apple b = banana d = lemon a = orange -------------------------------------------------- 3) ksort() Sorts an array by key, maintaining key to data correlations. This is useful mainly for associative arrays. <?php $fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); ksort($fruits); foreach ($fruits as $key => $val) { echo "$key = $val\n"; } ?> --------------------OUTPUT---------------------------- a = orange b = banana c = apple d = lemon ------------------------------------------------------

Answer
The sort() function sort the array. Element will arranged in lowest to highest when function has completed. The assort() function sort the associative arrays and where the actual element order is significant. The Ksort() function sort an array by key. This is useful for associative array.

Answer
Sort-sorting arry <?php $fruits = array("lemon", "orange", "banana", "apple"); sort($fruits); foreach ($fruits as $key => $val) { echo "fruits[" . $key . "] = " . $val . "\n"; } ?> The above example will output: fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange Assort-Sort an array and maintain index association <?php $fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); asort($fruits); foreach ($fruits as $key => $val) { echo "$key = $val\n"; } ?> The above example will output: c = apple b = banana d = lemon a = orange ksort — Sort an array by key <?php $fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); ksort($fruits); foreach ($fruits as $key => $val) { echo "$key = $val\n"; } ?> The above example will output: a = orange b = banana c = apple d = lemon

Answer
Sort-sorting arry <?php $fruits = array("lemon", "orange", "banana", "apple"); sort($fruits); foreach ($fruits as $key => $val) { echo "fruits[" . $key . "] = " . $val . "\n"; } ?> The above example will output: fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange Assort-Sort an array and maintain index association <?php $fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); asort($fruits); foreach ($fruits as $key => $val) { echo "$key = $val\n"; } ?> The above example will output: c = apple b = banana d = lemon a = orange ksort — Sort an array by key <?php $fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); ksort($fruits); foreach ($fruits as $key => $val) { echo "$key = $val\n"; } ?> The above example will output: a = orange b = banana c = apple d = lemon

Answer
sort() -> sorting the value in ascending.d assort() -> sorting only the value. Example: $x=array([0]=>32,[1]=>11,[2]=>10) print_r(asort($x); means: [2]=>10,[1]=>11,[0]=>32 Ksort() -> Sorting only key not value

Answer
In array we can get both key value and array value.key is refer for index,array is what we are storing.sort() use to sort in ascendending array value.arsort() user array in reverse order. ksort means key valuesare arranged in ascending order

Answer
sort() will order the array by its values without preserving the keys. Use it when array is indexed numerically or when you do not care about the keys. asort() will also sort the array by its values, but it will preserve the key -> value association. The ksort() function sorts an array by the keys. The values keep their original keys. This function returns TRUE on success, or FALSE on failure.

Answer
The sort() function sorts an array by the values. This function assigns new keys for the elements in the array. Existing keys will be removed. This function returns TRUE on success, or FALSE on failure. The asort() function sorts an array by the values. The values keep their original keys. This function returns TRUE on success, or FALSE on failure. The ksort() function sorts an array by the keys. The values keep their original keys. This function returns TRUE on success, or FALSE on failure.

Answer
bool sort ( array &$array [, int $sort_flags] ) This function sorts an array. Elements will be arranged from lowest to highest when this function has completed. Note: This function assigns new keys for the elements in array. It will remove any existing keys you may have assigned, rather than just reordering the keys. Returns TRUE on success or FALSE on failure. Example 329. sort() example <?php $fruits = array("lemon", "orange", "banana", "apple"); sort($fruits); foreach ($fruits as $key => $val) { echo "fruits[" . $key . "] = " . $val . "\n"; } ?> The above example will output: fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange

Answer
bool sort ( array &$array [, int $sort_flags] ) This function sorts an array. Elements will be arranged from lowest to highest when this function has completed. Note: This function assigns new keys for the elements in array. It will remove any existing keys you may have assigned, rather than just reordering the keys. Returns TRUE on success or FALSE on failure. Example 329. sort() example <?php $fruits = array("lemon", "orange", "banana", "apple"); sort($fruits); foreach ($fruits as $key => $val) { echo "fruits[" . $key . "] = " . $val . "\n"; } ?> The above example will output: fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange

Answer
sort() void sort(array target_array [, int sort_flags]) The sort() function sorts the target_array, ordering elements from lowest to highest value. Note that it doesn’t return the sorted array. Instead, it sorts the array “in place,” returning nothing, regardless of outcome. The optional sort_flags parameter modifies the function’s default behavior in accordance with its assigned value: • SORT_NUMERIC: Sort items numerically. This is useful when sorting integers or floats. • SORT_REGULAR: Sort items by their ASCII value. This means that B will come before a, for instance. A quick search online will produce several ASCII tables. • SORT_STRING: Sort items in a fashion that might better correspond with how a human might perceive the correct order. See natsort() for further information about this matter, introduced later in this section. Consider an example. Suppose you wanted to sort exam grades from lowest to highest: $grades = array(42,57,98,100,100,43,78,12); sort($grades); print_r($grades); The outcome looks like this: Array ( [0] => 12 [1] => 42 [2] => 43 [3] => 57 [4] => 78 [5] => 98 [6] => 100 [7] => 100 ) It’s important to note that key/value associations are not maintained. Consider the following example: $states = array("OH" => "Ohio", "CA" => "California", "MD" => "Maryland"); sort($states); print_r($states); Here’s the output: Array ( [0] => California [1] => Maryland [2] => Ohio )

Answer
sort destroy key association asort keeps key association of values. ksost sort the key value only


Goto Page:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Share |

PHP Objective Questions And Answers

PHP Objective Questions And Answers

PHP Interview Questions And Answers

PHP Subjective Questions And Answers


R4R,PHP Objective, PHP Subjective, PHP Interview Questions And Answers,PHP,PHP Interview,PHP Questions ,PHP Answers

New Updates

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R