Search Results

Search found 16413 results on 657 pages for 'array manipulation'.

Page 11/657 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Peek ahead when iterating an array in PHP 5.2

    - by pako
    Is it possible to "peek ahead" while iterating an array in PHP 5.2? For example, I often use foreach to manipulate data from an array: foreach($array as $object) { // do something } But I often need to peek at the next element while going through the array. I know I could use a for loop and reference the next item by it's index ($array[$i+1]), but it wouldn't work for associative arrays. Is there any elegant solution for my problem, perhaps involving SPL?

    Read the article

  • C# Array or Dictionary?

    - by Valentin
    Hi. I wanted to know is C# array has a constant access speed? I need to store 1000 items in static array, that will be initialized during server startup. This array will be used readonly, so there will be no changes to array. Should I use a simple C# array (new MyClass[]) or Dictionary instead. I am really new to C# and trying to understand how C# arrays access works. Can they be compared to c++ arrays by speed?

    Read the article

  • Send multidimensional array to php with jQuery

    - by robertdd
    hy, i have a little, big problem here :) after i upload some images i get a list with all the images. I have some jQuery function for rotate, duplicate, delete, shuffle images! when i select a image and hit delete i send a post to php with the alt="" value of the image,i identify the picture and edit. I want to make a save button, Instead of sending a post every time i rotate a image, better send a post after editing the list of images with an array that contains all data? my php array after upload looks like this: [files] => Array ( [lcxkijgr] => lcxkijgr.jpg [xcewxpfv] => xcewxpfv.jpg [rtiurwxf] => rtiurwxf.jpg [gsbxdsdc] => gsbxdsdc.jpg ) say that I uploaded 4 pictures, firs picture i rotate 90 degrees second i want to duplicate third i rotate 270 degrees and the fourth image i delete i can do all this only with jQuery, but on the server the images are the same, after a refresh the images are the same this is the list with the images: <div class="upimage"> <ul id="upimagesQueue"> <li id="upimagesHPVEJM"> <a href="javascript:jQuery('#upimagesHPVEJM').showlargeimage('HPVEJM')"> <img alt="lcxkijgr" src="uploads/s6id9r9icnp8q9102h8md9kfd7/lcxkijgr.jpg?1272087830477" id="HPVEJM" style="display: block;" > </a> </li> <li id="upimagesSTCSAV"> <a href="javascript:jQuery('#upimagesSTCSAV').showlargeimage('STCSAV')"> <img alt="xcewxpfv" src="uploads/s6id9r9icnp8q9102h8md9kfd7/xcewxpfv.jpg?1272087831360" id="STCSAV" style="display: block;" > </a> </li> <li id="upimagesBFPUEQ"> <a href="javascript:jQuery('#upimagesBFPUEQ').showlargeimage('BFPUEQ')"> <img alt="rtiurwxf" src="uploads/s6id9r9icnp8q9102h8md9kfd7/rtiurwxf.jpg?1272087832162" id="BFPUEQ" style="display: block;" > </a> </li> <li id="upimagesRKXNSV"> <a href="javascript:jQuery('#upimagesRKXNSV').showlargeimage('RKXNSV')"> <img alt="gsbxdsdc" src="uploads/s6id9r9icnp8q9102h8md9kfd7/gsbxdsdc.jpg?1272087832957" id="RKXNSV" style="display: block;"> </a> </li> <ul> </div> is ok if i make one array like this: array{ imgFromLi = array(img1,img2,img3,img4,img5,img6) rotate = array{img1=90, img2=270, img3=90} delete = array{img4,img5,img6} duplicate = array{img2, img3} } how i can make/send/cache this array?? sorry for my very bad english

    Read the article

  • PHP: separate value in array according to alphabate order

    - by Sanjay
    hi, i want to find values in array according to alphabate and want to make list in of array values according to alphabate order. my array is like that: Array ( [0] = Array ( [0] = Adidas [1] = AKG [2] = Apple [3] = Barrats [4] = Canon [5] = Dell [6] = Dixons [7] = HTC [8] = Liverpool [9] = Microsoft [10] = Pirelli Tyres [11] = ) ) and i want to make a list of values according to alphabate like this: A Adidas AKG plz any idea?

    Read the article

  • How do I generate an Array string from an array in memory (php).

    - by Itay Moav
    I need to create a big array in my code, I have the values in several tables (for easy management). I select it and now I have all the values in an array, in memory in the way I want. My problem, I need to write this array down, into the code. Is there a way to take an array which sits in the memory and translate it into a string "array('g'='h','b'='d'....)" which I can then echo and just copy-paste into my code?

    Read the article

  • Generating Deep Arrays: Shallow to Deep, Deep to Shallow or Bad idea?

    - by MobyD
    I'm working on an array structure that will be used as the data source for a report template in a web app. The data comes from relatively complex SQL queries that return one or many rows as one dimensional associative arrays. In the case of many, they are turned into two dimensional indexed array. The data is complex and in some cases there is a lot of it. To save trips to the database (which are extremely expensive in this scenario) I'm attempting to get all of the basic arrays (1 and 2 dimension raw database data) and put them, conditionally, into a single, five level deep array. Organizing the data in PHP seems like a better idea than by using where statements in the SQL. Array Structure Array of years( year => array of types( types => array of information( total => value, table => array of data( index => db array ) ) ) ) My first question is, is this a bad idea. Are arrays like this appropriate for this situation? If this would work, how should I go about populating it? My initial thought was shallow to deep, but the more I work on this, the more I realize that it'd be very difficult to abstract out the conditionals that determine where each item goes in the array. So it seems that starting from the most deeply nested data may be the approach I should take. If this is array abuse, what alternatives exist?

    Read the article

  • Ad-hoc String Manipulation With Visual Studio

    - by Liam McLennan
    Visual studio supports relatively advanced string manipulation via the ‘Quick Replace’ dialog. Today I had a requirement to modify some html, replacing line breaks with unordered list items. For example, I need to convert: Infrastructure<br/> Energy<br/> Industrial development<br/> Urban growth<br/> Water<br/> Food security<br/> to: <li>Infrastructure</li> <li>Energy</li> <li>Industrial development</li> <li>Urban growth</li> <li>Water</li> <li>Food security</li> This cannot be done with a simple search-and-replace but it can be done using the Quick Replace regular expression support. To use regular expressions expand ‘Find Options’, check ‘Use:’ and select ‘Regular Expressions’ Typically, Visual Studio regular expressions use a different syntax to every other regular expression engine. We need to use a capturing group to grab the text of each line so that it can be included in the replacement. The syntax for a capturing group is to replace the part of the expression to be captured with { and }. So my regular expression: {.*}\<br/\> means capture all the characters before <br/>. Note that < and > have to be escaped with \. In the replacement expression we can use \1 to insert the previously captured text. If the search expression had a second capturing group then its text would be available in \2 and so on. Visual Studio’s quick replace feature can be scoped to a selection, the current document, all open documents or every document in the current solution.

    Read the article

  • String manipulation functions in SQL Server 2000 / 2005

    - by Vipin
    SQL Server provides a range of string manipulation functions. I was aware of most of those in back of the mind, but when I needed to use one, I had to dig it out either from SQL server help file or from google. So, I thought I will list some of the functions which performs some common operations in SQL server. Hope it will be helpful to you all. Len (' String_Expression' ) - returns the length of input String_Expression. Example - Select Len('Vipin') Output - 5 Left ( 'String_Expression', int_characters ) - returns int_characters characters from the left of the String_Expression.     Example - Select Left('Vipin',3), Right('Vipin',3) Output -  Vip,  Pin  LTrim ( 'String_Expression' ) - removes spaces from left of the input 'String_Expression'  RTrim ( 'String_Expression' ) - removes spaces from right of the input 'String_Expression' Note - To removes spaces from both ends of the string_expression use Ltrim and RTrim in conjunction Example - Select LTrim(' Vipin '), RTrim(' Vipin ') , LTrim ( RTrim(' Vipin ')) Output - 'Vipin ' , ' Vipin' , 'Vipin' (Single quote marks ' ' are not part of the SQL output, it's just been included to demonstrate the presence of space at the end of string.) Substring ( 'String_Expression' , int_start , int_length ) - this function returns the part of string_expression. Right ( 'String_Expression', int_characters ) - returns int_characters characters from the right of the String_Expression.

    Read the article

  • Selecting a multi-dimensional array in LINQ

    - by mckhendry
    I have a task where I need to translate a DataTable to a two-dimensional array. That's easy enough to do by just looping over the rows and columns (see example below). private static string[,] ToArray(DataTable table) { var array = new string[table.Rows.Count,table.Columns.Count]; for (int i = 0; i < table.Rows.Count; ++i) for (int j = 0; j < table.Columns.Count; ++j) array[i, j] = table.Rows[i][j].ToString(); return array; } What I'd really like to do is use a select statement in LINQ to generate that 2D array. Unfortunately it looks like there is no way in LINQ to select a multidimensional array. Yes, I'm aware that I can use LINQ to select a jagged array, but that's not what I want. Is my assumption correct, or is there a way to use LINQ to select a multi-dimensional array?

    Read the article

  • Convert a nested array into a flat array with PHP

    - by Ben Fransen
    Hello all, I'm trying to create a generic database mapping class with PHP. Collecting the data through my functions is going well, but as expected I'm retrieving a nested set. A print_r of my received array looks like: Array ( [table] => Session [columns] => Array ( [0] => `Session`.`ID` AS `Session_ID` [1] => `Session`.`User` AS `Session_User` [2] => `Session`.`SessionID` AS `Session_SessionID` [3] => `Session`.`ExpiresAt` AS `Session_ExpiresAt` [4] => `Session`.`CreatedAt` AS `Session_CreatedAt` [5] => `Session`.`LastActivity` AS `Session_LastActivity` [6] => `Session`.`ClientIP` AS `Session_ClientIP` ) [0] => Array ( [table] => User [columns] => Array ( [0] => `User`.`ID` AS `User_ID` [1] => `User`.`UserName` AS `User_UserName` [2] => `User`.`Password` AS `User_Password` [3] => `User`.`FullName` AS `User_FullName` [4] => `User`.`Address` AS `User_Address` ) [0] => Array ( [table] => Address [columns] => Array ( [0] => `Address`.`ID` AS `Address_ID` [1] => `Address`.`UserID` AS `Address_UserID` [2] => `Address`.`Street` AS `Address_Street` [3] => `Address`.`City` AS `Address_City` ) ) ) ) To simplify things I want to recreate this nested array to a flat array so I can easily loop through it and use the 'columns' key to create my SELECT query. I'm kinda struggling with this for a while now and figures, maybe some users at SO can help me out here. I've tried multiple things with recursion, all without luck so far... Any help is much appriciated! Thanks in advance, Ben Fransen

    Read the article

  • make array from a list of images with jquery

    - by robertdd
    i have a list of photos like this: <div class="upimage"> <ul id="upimagesQueue" class="thumbs ui-sortable"> <li id="upimagesKHGYUD"> <a href="uploads/0002.jpg"> <img src="uploads/0002.jpg" id="KHGYUD"> </a> </li> <li id="upimagesNCEEKI"> <a href="uploads/0003.jpg"> <img src="uploads/0003.jpg" id="NCEEKI"> </a> </li> <li id="upimagesPWSHUN"> <a href="uploads/0003.jpg"> <img src="uploads/0003.jpg" id="PWSHUN"> </a> </li> <li id="upimagesOYJAQV"> <a href="uploads/0004.jpg"> <img src="uploads/0004.jpg" id="OYJAQV"> </a> </li> </ul> </div> i want to make a function in jquery too get all the images in 1 array to be able to sent the array to php! the array i want to be in this form: array( 'image_id_1' => array( 'image_src_1' => 'xyz.jpg', ) 'image_id_2' => array( 'image_src_2' => 'xyz.jpg', ) 'image_id_3' => array( 'image_src_3' => 'xyz.jpg', ) 'image_id_4' => array( 'image_src_4' => 'xyz.jpg', ) ) how i can code this? thanks

    Read the article

  • Merge the sub array if it has the save id value?

    - by sophie
    I have an array and I want to merge the sub array that have the same id value together: <?php $a = Array( Array ( "id" => 1, "id_categorie" => 1, "nb" => 18 ), Array ( "id" => 1, "id_categorie" => 8, "nb" => 14 ), Array ( "id" => 2, "id_categorie" => 10, "nb" => 15 ) ); $result = array(); foreach ($a as $k=>$v){ $result[$v['id']] =$v; } echo '<pre>'; print_r($result); echo '</pre>'; ?> I GOT: Array ( [1] => Array ( [id] => 1 [id_categorie] => 8 [nb] => 14 ) [2] => Array ( [id] => 2 [id_categorie] => 10 [nb] => 15 ) ) BUT WHAT I WANT IS : Array ( [1] => Array ( Array ( "id_categorie" => 1, "nb" => 18 ), Array ( "id_categorie" => 8, "nb" => 14 ) ) [2] => Array ( [id_categorie] => 10 [nb] => 15 ) ) Anyone could tell me how to do this? thanks

    Read the article

  • numpy array assignment problem

    - by Sujan
    Hi All: I have a strange problem in Python 2.6.5 with Numpy. I assign a numpy array, then equate a new variable to it. When I perform any operation to the new array, the original's values also change. Why is that? Please see the example below. Kindly enlighten me, as I'm fairly new to Python, and programming in general. -Sujan >>> import numpy as np >>> a = np.array([[1,2],[3,4]]) >>> b = a >>> b array([[1, 2], [3, 4]]) >>> c = a >>> c array([[1, 2], [3, 4]]) >>> c[:,1] = c[:,1] + 5 >>> c array([[1, 7], [3, 9]]) >>> b array([[1, 7], [3, 9]]) >>> a array([[1, 7], [3, 9]])

    Read the article

  • C++ Converting image to integer array

    - by jonathanasdf
    How would I go about converting the pixels in an image (.png file) to an integer array, where each pixel is converted to its ARGB integer equivalent? I would like to do this without using external libraries. Not a 2D integer array by the way, a 1D one (where access is through array[row*width+col]). Thanks.

    Read the article

  • Find most significant bit (left-most) that is set in a bit array

    - by Claudiu
    I have a bit array implementation where the 0th index is the MSB of the first byte in an array, the 8th index is the MSB of the second byte, etc... What's a fast way to find the first bit that is set in this bit array? All the related solutions I have looked up find the first least significant bit, but I need the first most significant one. So, given 0x00A1, I want 9.

    Read the article

  • Setting last N bits in an array

    - by Martin
    I'm sure this is fairly simple, however I have a major mental block on it, so I need a little help here! I have an array of 5 integers, the array is already filled with some data. I want to set the last N bits of the array to be random noise. [int][int][int][int][int] set last 40 bits [unchanged][unchanged][unchanged][24 bits of old data followed 8 bits of randomness][all random] This is largely language agnostic, but I'm working in C# so bonus points for answers in C#

    Read the article

  • Array to Array pushing in Zend Session object

    - by kate-koopy
    Hello! I have some example of pushing array to array in session object: class someClass extends someOtherOne { ...////// some other code here that starts session and creates namespace public function __add2Session($a,$b) { $namespc = $this -> __getnewNameSpace(); //returns a Zend Session Namesapce (object) if (!isset($namespc -> {$a})) { $namespc -> {$a} = array(); } array_push($namespc -> {$a}, $b); } } ...///////////// $item=array(1=>"one",2=>"two",3=>"three",4=>"four",5=>"five",6=>"six",7=>"seven"); $k = new someClass(); $cart = new Zend_Session_Namespace('Cart'); $k -> __add2Session("items",$item); The result is when I reload the page several times - the value of $cart -> items in the session gets overwritten and not populated. Can somebody explain why it occurs and how do I fix this? I want to have $cart -> items to be an "array in array" like: $cart -> items = array(array(1=>"one",2=>"two"), array(1=>"two",2=>"three"));

    Read the article

  • Search and remove an element in mulit-dimentional array in php depending on a criteria

    - by Nadeem
    I've a simple question about multi-dim array, I want to remove any redundent element let's say in my case, [serviceMethod] => PL is coming 2 times, I want to search 'PL' with respect of [APIPriceTax] if an element has a lower price I want to keep it and remove the other one in array Array ( [0] => Array ( [carrierIDs] => 150 [serviceMethod] => CP [APIPriceTax] => 30.63 [APIPriceWithOutTax] 28.32 [APIServiceName] => Xpresspost USA [APIExpectedTransitDay] => 2 ) [1] => Array ( [carrierIDs] => 155 [serviceMethod] => PL [APIPriceTax] => 84.13 [APIPriceWithOutTax] => 73.8 [APIServiceName] => PurolatorExpressU.S. [APIExpectedTransitDay] => 1 ) [2] => Array ( [carrierIDs] => 164 [serviceMethod] => PL [APIPriceTax] => 25.48 [APIPriceWithOutTax] => 22.35 [APIServiceName] => PurolatorGroundU.S. [APIExpectedTransitDay] => 3 ) ) This is my pseudo code: Where $carrierAddedToList is the actual array $newCarrierAry = function($carrierAddedToList) { $newArray = array(); foreach($carrierAddedToList as $cV => $cK) { if( !in_array($cK['serviceMethod'],$newArray) ) { array_push($newArray, $cK['serviceMethod']); } } return $newArray; } ; print_r($newCarrierAry($carrierAddedToList));

    Read the article

  • Search for values in nested array

    - by dardub
    I have an array as follows array(2) { ["operator"] => array(2) { ["qty"] => int(2) ["id"] => int(251) } ["accessory209"] => array(2) { ["qty"] => int(1) ["id"] => int(209) } ["accessory211"] => array(2) { ["qty"] => int(1) ["id"] => int(211) } } I'm trying to find a way to verify an id value exists within the array and return bool. I'm trying to figure out a quick way that doesn't require creating a loop. Using the in_array function did not work, and I also read that it is quite slow. In the php manual someone recommended using flip_array() and then isset(), but I can't get it to work for a 2-d array. doing something like if($array['accessory']['id'] == 211) would also work for me, but I need to match all keys containing accessory -- not sure how to do that Anyways, I'm spinning in circles, and could use some help. This seems like it should be easy. Thanks.

    Read the article

  • search array and get array key

    - by SoulieBaby
    Hi all, I have an array, which I'd like to search for a value in and retreive the array key if it exists, but not sure how to even go about doing that. Here's my array: Array ( [hours] => Array ( [0] => 5 [1] => 5 [2] => 6 [3] => 6 [4] => 8 [5] => 10 ) ) So I'd like to search the hours array for 10, if 10 exists in the array, I want the key (5) to be returned. If that makes sense? Am trying to do it dynamically so the search string (10) will change, but I figure if I can get it working for number 10, I can get it working with a variable number :)

    Read the article

  • LabVIEW: converting numeric array to string array

    - by JaysonFix
    Using LabVIEW 2009, I have a VI that outputs an array of U64 integers. I'd like the user to be able to perform discrete selection from among the elements of this array. I'm thinking of accomplishing this by programmatically populating a Menu Ring (as shown at http://digital.ni.com/public.nsf/allkb/FB0409491FAB16FA86256D08004FCE7E). However, I apparently need to convert my array of U64 ints to an array of strings, as it is an array of strings that is used to populate the Menu Ring. My question: how can I convert the array of U64 ints to an array of strings?

    Read the article

  • How to find an array from parent array

    - by Me-and-Coding
    Hi, I am using below code to find an array inside parent array but it is not working that is retuning empty even though the specified key exits in the parent array. $cards_parent = $feedData['BetradarLivescoreData']['Sport']['Category']['Tournament']['Match']; $cards = array(); foreach($cards_parent as $key => $card) { if ($key === 'Cards') { $cards[] = $cards_parent[$key]; break; } } Do you know any array function that will search parent array for specified key and if found it will create an array starting from that key. Thanks

    Read the article

  • generate an array from an array with conditions

    - by Aman
    Suppose i have an array $x = (31,12,13,25,18,10); I want to reduce this array in such a way that the value of each array element is 32. so after work my array will become $newx = (32,32,32,13); I have to generate this array in such a way the sum of array values is never greater than 32. so to create first value, i will reduce 1 from second index value i.e. 12, so the second value will become 11 and first index value will become 31+1 =32. This process should continue so that each array value becomes equal to 32.

    Read the article

  • Getting certain array from a multidimensional array

    - by Leron
    I have multidimensional array which is a query returning the info from a table named 'users'. In another part of my code I need to get the records of only one certain user and I want to take it using the array I mentioned above. It's of type: array(24) { [0]=>array(9) { ["id"]=>string(1) "1" ... } [1]=>array(9) { ["id"]=>string(1) "2" ... } [2]=>array(9) { ["id"]=>string(1) "5" ...} I'll use foreach compairing by ["id"] to find the record I need, but when I get a match I'm not sure how to extract only this array from the parent one. Thanks Leron

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >