This is a discussion on Using Arrays in PHP within the PHP Programming forums, part of the Web Development category; can we discuss briefly about the efficient ways of Using Arrays in PHP ?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| can we discuss briefly about the efficient ways of Using Arrays in PHP ?
__________________ Thanks & Regards Sabari... Last edited by Sabari : 08-21-2007 at 09:49 PM. |
|
#2
| |||
| |||
| A brief introduction to PHP Arrays: In PHP we can do magic with the Array Functions which will allow you to interact with and manipulate arrays in various ways. Arrays are essential for storing, managing and operating on sets of variables. Simple and multi-dimensional arrays are supported in PHP and it may be either user created or created by another function. There are specific database handling functions for populating arrays from database queries and several functions return arrays.
__________________ With, J. Jeyaseelan Everything Possible |
|
#3
| |||
| |||
| Hi Guys, Here i have two arrays $a = array(0,2,3,4) $b = array(2,4) i want to get the new array which only have elements like array(0,3) which does not have the elements in $b So in this case we have to use array_diff functions as like this $newarray = array_diff($a,$b) $newarray contains the elements as (0,3)
__________________ With, J. Jeyaseelan Everything Possible |
|
#4
| |||
| |||
| hi all, Applies the callback to the elements of the given array. we can apply user defined function in each element of an array by this function. Eg: we can change all values to lower string an array by array_map function here example for that.. $inputarray = array("Hello","Buy It"); function funStrChange($pmArray) { return strtolower($pmArray); } $aResult = array_map("funStrChange", $inputarray); now, $aResult is: $aResult[0] = "hello"; $aResult[1] = "buy it"; |
|
#5
| |||
| |||
| hi all, is it possible to wild card search in an array? for eg: $vSearchStr = "hi"; $Array = array("hello","hi mathew"); here, i want to get the key value for $vSearchStr: how do i get the result for this? can any one give sample for this? |
|
#6
| |||
| |||
| it's very simple, but i'ts very difficult to get solution for this issue, here listed the coding to get the key values from given Array values. $vSearchStr = "hi"; $Array = array("hello","hi mathew"); $Search=array(); foreach($Array as $key => $value) { if(ereg($vSearchStr,$value)) { $Search[$key]=$value; } } print_r($key); i think it's very useful for you ![]()
__________________ Thanks & Regards Sabari... Last edited by Sabari : 08-21-2007 at 09:49 PM. |
|
#7
| |||
| |||
| Hi sabari, Its ok, but ive made one small change in your code. It is checking only case sensitive in array... so i have changed just one function : ereg to eregi. Now its working case insensitive. $vSearchStr = "hi"; $Array = array("hello","hi mathew"); $Search=array(); foreach($Array as $key => $value) { if(eregi($vSearchStr,$value)) { $Search[$key]=$value; } } print_r($key); |
|
#8
| |||
| |||
| What is maximum size of a normal variable & array variable? OR is there any default size available? Pls help me. Thanks |
|
#9
| |||
| |||
| Can anyone of you explain array_random ? Last edited by senraj : 08-14-2007 at 07:32 AM. |
|
#10
| |||
| |||
| hi, array_rand function gets the random values from an array. $input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank"); $rand_keys = array_rand($input, 2); //#-- 1st parameter is Array for your random entries //#-- 2nd Parameter is number of picked element, ie, how many random you //# want to get from this array echo $input[$rand_keys[0]] . "\n"; echo $input[$rand_keys[1]] . "\n"; |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Jagged Arrays in C# | vigneshgets | C# Programming | 4 | 09-30-2008 03:48 AM |
| Using arrays in stored procedures | it.wily | Database Support | 2 | 02-09-2008 09:18 AM |
| Classic asp arrays and recordset | ramesh123 | ASP and ASP.NET Programming | 1 | 12-02-2007 07:44 PM |
| Arrays in Java | leoraja8 | Java Programming | 7 | 11-19-2007 12:23 AM |
| Java:Tutorial - Arrays | pranky | Java Programming | 0 | 02-23-2007 11:54 PM |
Our Partners |