Search Results

Search found 42698 results on 1708 pages for 'php in array'.

Page 98/1708 | < Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >

  • Can this be done in 1 line?

    - by Angelo
    Can this be done in 1 line with PHP? Would be awesome if it could: $out = array("foo","bar"); echo $out[0]; Something such as: echo array("foo","bar")[0]; Unfortunately that's not possible. Would it be possible like this? So I can do this for example in 1 line: echo array(rand(1,100), rand(1000,2000))[rand(0,1)]; So let's say I have this code: switch($r){ case 1: $ext = "com"; break; case 2: $ext = "nl"; break; case 3: $ext = "co.uk"; break; case 4: $ext = "de"; break; case 5: $ext = "fr"; break; } That would be much more simplified to do it like this: $ext = array("com","nl","co.uk","de","fr")[rand(1,5)];

    Read the article

  • PHP header redirection does not reload <iframe> in IE

    - by Marco Demaio
    When displaying data from DB usually I'm in this situation I'm in page A.php that shows data from DB, user performs some action (like edit/delete etc) and page B.php is loaded to perform the action, once page B performed the action, it redirects browser to page A, page A is auto reloaded during step (3) therefor it shows an updated situation of the data In order to make page B to redirect to page A i use a simple PHP header("Location: " . "A.php", TRUE, 302); This works well in all situations, except when pages A.php is displaied into an <iframe>: in such a case it does not reload (step 4 does not get done). This seems to happen only in IE7 (don't know about IE8), it works perfectly on FF/Safari. And only when using an <iframe>, if page A.php is not in <iframe> it gest refreshed also in IE7. In order to solve this I simply added a couple of headers in page A.php to set it to not be cached: header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past But I was curious if you might have experienced the same issue too in the past, and if you good give me some advice about this?

    Read the article

  • Any array function or user defined function to pick up only first occurence of value from the array?

    - by OM The Eternity
    If i have an array Array ( [0] => Array ( [0] => 137 [id] => 137 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => 0 [oldvalue] => 0 [5] => 62 [newvalue] => 62 [6] => checked_out [field] => checked_out [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:28 [changedone] => 2010-05-11 17:46:28 ) [1] => Array ( [0] => 138 [id] => 138 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => 0000-00-00 00:00:00 [oldvalue] => 0000-00-00 00:00:00 [5] => 2010-05-11 12:16:28 [newvalue] => 2010-05-11 12:16:28 [6] => checked_out_time [field] => checked_out_time [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:28 [changedone] => 2010-05-11 17:46:28 ) [2] => Array ( [0] => 139 [id] => 139 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => Subhash [oldvalue] => Subhash [5] => Subhashgfhfgh [newvalue] => Subhashgfhfgh [6] => name [field] => name [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:35 [changedone] => 2010-05-11 17:46:35 ) [3] => Array ( [0] => 140 [id] => 140 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => subhash [oldvalue] => subhash [5] => subhashhfhf [newvalue] => subhashhfhf [6] => alias [field] => alias [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:35 [changedone] => 2010-05-11 17:46:35 ) [4] => Array ( [0] => 141 [id] => 141 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => 62 [oldvalue] => 62 [5] => 0 [newvalue] => 0 [6] => checked_out [field] => checked_out [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:35 [changedone] => 2010-05-11 17:46:35 ) [5] => Array ( [0] => 142 [id] => 142 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => 2010-05-11 12:16:28 [oldvalue] => 2010-05-11 12:16:28 [5] => 0000-00-00 00:00:00 [newvalue] => 0000-00-00 00:00:00 [6] => checked_out_time [field] => checked_out_time [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:35 [changedone] => 2010-05-11 17:46:35 ) ) Now here u can see that the index "field" has repeated values i.e. "checked_out" and "checked_out_time" other indexes have single occurrence, now what should I do to select/grab the first occurrence of the repetitive values only?

    Read the article

  • Javascript array of dates - not iterating properly (jquery ui datepicker)

    - by PaulB
    Hi I have some code which builds an array of date ranges. I then call a function, passing it a date, and compare that date with dates in the array. I'm doing it this way because the dates are stored in a cms, and I'm manipulating the JqueryUI datepicker. Unfortunately my code only checks the first date range in the array - and I can't figure out why! I think it's probably something simple (/stupid!) - if anyone can shed some light on it I'd be extremely grateful! The code is below - the june-september range works fine, the december to jan is totally ignored... <script type="text/javascript" language="javascript"> var ps1 = new Date(2010, 06-1, 18); var pe1 = new Date(2010, 09-1, 03); var ps2 = new Date(2010, 12-1, 20); var pe2 = new Date(2011, 01-1, 02); var peakStart = new Array(ps1,ps2); var peakEnd = new Array(pe1,pe2); function checkDay(date) { var day = date.getDay(); for (var i=0; i<peakStart.length; i++) { if ((date > peakStart[i]) && (date < peakEnd[i])) { return [(day == 5), '']; } else { return [(day == 1 || day == 5), '']; } } } </script>

    Read the article

  • sort array with special characters in php

    - by Enkay
    I have an array I'm trying to asort using php. The problem is that the array has accented characters in it and needs to be sorted using "french" rules. cote < côte < coté < côté I've tried many things, like using php collators, but I get the following error : PHP Fatal error: Class 'Collator' not found I've also tried to set locale but it didn't do anything so I'm not sure I was doing it right, or if I need to isntall the locale. I'm a little confused. I'm using PHP 5.2.4 if that helps. If I use asort without anything, it puts all the words with accented characters at the end. Thanks.

    Read the article

  • Fast serarch of 2 dimensional array

    - by Tim
    I need a method of quickly searching a large 2 dimensional array. I extract the array from Excel, so 1 dimension represents the rows and the second the columns. I wish to obtain a list of the rows where the columns match certain criteria. I need to know the row number (or index of the array). For example, if I extract a range from excel. I may need to find all rows where column A =”dog” and column B = 7 and column J “a”. I only know which columns and which value to find at run time, so I can’t hard code the column index. I could use a simple loop, but is this efficient ? I need to run it several thousand times, searching for different criteria each time. For r As Integer = 0 To UBound(myArray, 0) - 1 match = True For c = 0 To UBound(myArray, 1) - 1 If not doesValueMeetCriteria(myarray(r,c) then match = False Exit For End If Next If match Then addRowToMatchedRows(r) Next The doesValueMeetCriteria function is a simple function that checks the value of the array element against the query requirement. e.g. Column A = dog etc. Is it more effiecent to create a datatable from the array and use the .select method ? Can I use Linq in some way ? Perhaps some form of dictionary or hashtable ? Or is the simple loop the most effiecent ? Your suggestions are most welcome.

    Read the article

  • How can I enable readline for PHP 5.4 on Ubuntu 11.10?

    - by dotweb
    I installed PHP 5.4 on my Ubuntu 11.10 PC like this: $ sudo add-apt-repository ppa:ondrej/php5 $ sudo apt-get update $ sudo apt-get install php5 It's working fine but I don't have the readline function anymore that I need for my PHP CLI scripts. libreadline-dev is installed and readline was working perfectly in 5.3. I also tried to compile 5.4 with readline: $ wget http://de2.php.net/get/php-5.4.0.tar.gz/from/de.php.net/mirror $ tar xzvf mirror $ cd php-5.4.0/ $ ./configure --with-readline $ make test But the last command echoed this error after compiling for some minutes: FAILED TEST SUMMARY Test 7: DTD tests [ext/dom/tests/dom007.phpt] You may have found a problem in PHP. I appreciate any help on how to get readline working!

    Read the article

  • Read from a file into an array and stop if a ":" is found in ruby

    - by Minky
    Hi! How can I in Ruby read a string from a file into an array and only read and save in the array until I get a certain marker such as ":" and stop reading? Any help would be much appreciated =) For example: 10.199.198.10:111 test/testing/testing (EST-08532522) 10.199.198.12:111 test/testing/testing (EST-08532522) 10.199.198.13:111 test/testing/testing (EST-08532522) Should only read the following and be contained in the array: 10.199.198.10 10.199.198.12 10.199.198.13

    Read the article

  • PHP array pointer craziness

    - by JMan
    I'm trying to create a "GetCurrentLevel" method that takes a point value as an input and returns what "Level" that corresponds to. I'm storing the Level = Points mapping in an array, but the array pointer is not moving logically when I use it a foreach loop. I've added echo statements for debugging. Here's my class definition: class Levels extends Model { protected $_map = array ( 'None' => 0, 'Bronze' => 50, 'Silver' => 200, 'Gold' => 500 ); public function __construct() { parent::__construct(); } public function GetCurrentLevel($points) { foreach ($this->_map as $name => $threshold) { echo "Level Name: $name<br/>"; echo "Level Threshold: $threshold<br/>"; echo "Current Level: " . key($this->_map) . "<br/>"; echo "Current Threshold: " . current($this->_map) . "<br/>"; if ($points < $threshold) /* Threshold is now above the points, so need to go back one level */ { $previousThreshold = prev($this->_map); echo "Previous Threshold: $previousThreshold<br/>"; echo "Final Level: " . key($this->_map) . "<br/>"; return key($this->_map); } echo "Go to next level <br/>"; } } And here is what I see when I call GetCurrentLevel(60): Level Name: None Level Threshold: 0 Current Level: Bronze //* Looks like foreach immediately moves the array pointer *// Current Threshold: 50 Go to next level Level Name: Bronze Level Threshold: 50 Current Level: Bronze //* WTF? Why hasn't the array pointer moved? *// Current Threshold: 50 Go to next level Level Name: Silver Level Threshold: 200 Current Level: Bronze //* WTF? Why hasn't the array pointer moved? *// Current Threshold: 50 Previous Threshold: 0 Final Level: None But the "Final Level" should be 'Bronze' since 60 points is above the 50 points needed for a Bronze medal, but below the 200 points needed for a Silver medal. Sorry for the long post. Thanks for your help!

    Read the article

  • I want to use contents of String or Array in an IF ELSE statement for iphone

    - by Michael Robinson
    I want to check to see if an array is empty to activate a shipping method. Here is the code for returning the array. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *fullFileName = [NSString stringWithFormat:@"%@/arraySaveFile", documentsDirectory]; NSMutableArray *array = [[NSMutableArray alloc] initWithContentsOfFile:fullFileName]; I want to write something like: if NSString *fullFileName ="" ; [nnNEP EnableShipping]; else [nnNEP DisableShipping]; OR if array contents ="" ; [nnNEP EnableShipping]; else [nnNEP DisableShipping]; I just can't find the right or description on how to do this properly. Thanks,

    Read the article

  • Iterate with binary structure over numpy array to get cell sums

    - by Curlew
    In the package scipy there is the function to define a binary structure (such as a taxicab (2,1) or a chessboard (2,2)). import numpy from scipy import ndimage a = numpy.zeros((6,6), dtype=numpy.int) a[1:5, 1:5] = 1;a[3,3] = 0 ; a[2,2] = 2 s = ndimage.generate_binary_structure(2,2) # Binary structure #.... Calculate Sum of result_array = numpy.zeros_like(a) What i want is to iterate over all cells of this array with the given structure s. Then i want to append a function to the current cell value indexed in a empty array (example function sum), which uses the values of all cells in the binary structure. For example: array([[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 2, 1, 1, 0], [0, 1, 1, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) # The array a. The value in cell 1,2 is currently one. Given the structure s and an example function such as sum the value in the resulting array (result_array) becomes 7 (or 6 if the current cell value is excluded). Someone got an idea?

    Read the article

  • execute a string of PHP code on the command line

    - by Matthew J Morrison
    I'd like to be able to run a line of PHP code on the command line similar to how the following options work: :~> perl -e "print 'hi';" :~> python -c "print 'hi'" :~> ruby -e "puts 'hi'" I'd like to be able to do: :~> php "echo 'hi';" I've read that there is a -r option that can do what I need for php, however it doesn't appear to be available when I try to use it. I've tried using PHP 5.2.13 and PHP 4.4.9 and neither have an -r option available. I wrote this script (that I called run_php.php) - which works, but I'm not a huge fan of it just because I feel like there should be a more "correct" way to do it. #!/usr/bin/php5 -q <?php echo eval($argv[1]); ?> My question is: is there a -r option? If so, why is it not available when I run --help? If there is no -r option, what is the best way to do this (without writing an intermediary script if possible)? Thanks!

    Read the article

  • Any array function or user defned function to pick up only first occurance of value from the array?

    - by OM The Eternity
    If i have an array Array ( [0] => Array ( [0] => 137 [id] => 137 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => 0 [oldvalue] => 0 [5] => 62 [newvalue] => 62 [6] => checked_out [field] => checked_out [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:28 [changedone] => 2010-05-11 17:46:28 ) [1] => Array ( [0] => 138 [id] => 138 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => 0000-00-00 00:00:00 [oldvalue] => 0000-00-00 00:00:00 [5] => 2010-05-11 12:16:28 [newvalue] => 2010-05-11 12:16:28 [6] => checked_out_time [field] => checked_out_time [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:28 [changedone] => 2010-05-11 17:46:28 ) [2] => Array ( [0] => 139 [id] => 139 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => Subhash [oldvalue] => Subhash [5] => Subhashgfhfgh [newvalue] => Subhashgfhfgh [6] => name [field] => name [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:35 [changedone] => 2010-05-11 17:46:35 ) [3] => Array ( [0] => 140 [id] => 140 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => subhash [oldvalue] => subhash [5] => subhashhfhf [newvalue] => subhashhfhf [6] => alias [field] => alias [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:35 [changedone] => 2010-05-11 17:46:35 ) [4] => Array ( [0] => 141 [id] => 141 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => 62 [oldvalue] => 62 [5] => 0 [newvalue] => 0 [6] => checked_out [field] => checked_out [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:35 [changedone] => 2010-05-11 17:46:35 ) [5] => Array ( [0] => 142 [id] => 142 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => 2010-05-11 12:16:28 [oldvalue] => 2010-05-11 12:16:28 [5] => 0000-00-00 00:00:00 [newvalue] => 0000-00-00 00:00:00 [6] => checked_out_time [field] => checked_out_time [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:35 [changedone] => 2010-05-11 17:46:35 ) ) Now here u can see that the index "field" has repeated values i.e. "checked_out" and "checked_out_time" other indexes have single occurrence, now what should I do to select/grab the first occurrence of the repetitive values only?

    Read the article

  • Get XML-RPC (Andorid - PHP) web service different params type

    - by Jovan
    Hi, I want to create XML-RPC web service for Andorid (client) - PHP (Server) communication I create XML-RPC PHP web service server using this tutorial: http://articles.sitepoint.com/article/own-web-service-php-xml-rpc/5 For andorid client web service I use this project: http://code.google.com/p/android-xmlrpc/ server and client communication is OK, but I have problem with getting params from andorid client to php server. From andorid client I send two params (first integer and second float number) Object[] params = { 3, 3.6f, }; method.call(params); , but I don't know how to handle this parameters in php server?? in php server there is some function , but with only one param ($news_id): function news_viewNewsItem ( $news_id ) { /* Define the query to fetch the news item */ $query = "SELECT * FROM kd_xmlrpc_news WHERE news_id = '" . $news_id . "'"; $sql = mysql_query ( $query ); if ( $result = mysql_fetch_array ( $sql ) ) { /* Extract the variables for sending in our server response */ $news_item['news_id'] = $result['news_id']; $news_item['date'] = XMLRPC_convert_timestamp_to_iso8601( mysql_datetime_to_timestamp( $result['date'] ) ); $news_item['title'] = $result['title']; $news_item['full_desc'] = $result['full_desc']; $news_item['author'] = $result['author']; /* Respond to the client with the news item */ XMLRPC_response(XMLRPC_prepare($news_item), KD_XMLRPC_USERAGENT); } else { /* If there was an error, respond with a fault code instead */ XMLRPC_error("1", "news_viewNewsItem() error: Unable to read news:" . mysql_error(), KD_XMLRPC_USERAGENT); } } In server.py file there is functions for every method but I dont know how to write in php server: def add(self, x, y): print print "input x=%s, y=%s" % (str(x), str(y)) sum = x + y print "output", sum print return sum Can some one help me with code , and tell me how to handle various types from client to server?? Thanks and Happy New Year

    Read the article

  • Do I need to recompile PHP to make use of CURL API?

    - by amn
    I have both Apache and PHP set up manually, albeit the latter without CURL. There is this jungle of instructions and explanations on extensions for PHP. I have a very straightforward question - what do I need to do to enable CURL in a more dynamic way. I resent the idea of static linking, in fact I hate and avoid static linking like the plague. Is it possible to have my Apache and PHP understand that there is CURL in town? I can compile CURL if necessary. Package management may be out of the question, because I built PHP myself - I am on Ubuntu, and it does not provide PHP without Suhosin and a a whole lot of time, so I removed it and built PHP myself. The whole slew of related questions simply propse installing "php5-curl" package, which is exactly one thing I CANNOT do since it installs it in a completely unrelated directory, which my PHP does not even seem to bother linking to.

    Read the article

  • PHP Array Key & value Question

    - by Nano HE
    Hi I writed a test code as below. <?php $url = 'http://localhost/events/result/cn_index.php?login'; print_r(parse_url($url)); echo parse_url($url, PHP_URL_PATH); ?> Output Array ( [scheme] => http [host] => localhost [path] => /events/result/cn_index.php [query] => login ) /events/result/cn_index.php Now I inserted the line below echo array[query]; // I want to echo 'login', but failed. How to the the value of 'login'?

    Read the article

  • How to configure Apache for PHP on Windows 7?

    - by salim cobra
    I have installed Apache 2.0(httpd-2.0.64-win32-x86-no_ssl) and it works, then I have installed Php5.3 and it pointed to Apache configuration folder. failed scenario: 1- create simple test.php, put in under C:\Apache\Apache2\htdocs 2- call "http://localhost:8080/test.php" -- "Bad Request..Your browser sent a request that this server could not understand." Proposed solution by NetBeans blog (failed) 1-add those two lines to httpd.conf AddType Application/x-httpd-php .php LoadModule php5_module "c:/php/sapi/php5apache2_2.dll" It doesnt works because there is no "php5apache2_2.dll" under my Php installation folder?? I have such .dll : php5ts.dll, ssleay32.dll,.. Any one have any suggestion in order to run the PHP script successfully?

    Read the article

  • Searching a 2D array for a range of values in java

    - by Paige O
    I have a 2^n size int array and I want to check if an element exists that is greater than 0. If the element exists, I want to divide the array by 4 and check if the coordinates of the found element are in the 1st, 2nd, 3rd or 4th quadrant of the array. For example, logically if the element exists in the first quadrant it would look something like this: If array[][] 0 && the row of that coordinate is in the range 0-(grid.length/2-1) && the column of that coordinate is in the range 0-(grid.length/2-1) then do something. I'm really not sure how to check the row and column index of the found element and store those coordinates to use in my if statement. Help!

    Read the article

  • How to declare array of 2D array pointers and access them?

    - by vikramtheone
    Hi Guys, How can I declare an 2D array of 2D Pointers? And later access the individual array elements of the 2D arrays. Is my approach correct? main() { int i, j; int **array[10][10]; int **ptr = NULL; for(i=0;i<10;i++) { for(j=0j<10;j++) { alloc_2D(&ptr, 10, 10); array[i][j] = ptr; } } //After I do this, how can I access the individual 2D array //and then the individual elements of the 2D arrays? } void alloc_2D(float ***memory, unsigned int rows, unsigned int cols) { float **ptr; *memory = NULL; ptr = malloc(rows * sizeof(float*)); if(ptr == NULL) { status = ERROR; printf("\nERROR: Memory allocation failed!"); } else { int i; for(i = 0; i< rows; i++) { ptr[i] = malloc(cols * sizeof(float)); if(ptr[i]==NULL) { status = ERROR; printf("\nERROR: Memory allocation failed!"); } } } *memory = ptr; }

    Read the article

  • VBA-Excel return multidimensional array from a function

    - by alesdario
    I'm trying to write a function which returns a multidimensional array. The problem is that the size of the array isn't defined. My array is initialized in the function below my_list() Dim my_list() As String Public Sub Load_My_List() Dim last_column As Integer last_column = some_helper.Get_Last_Column(somw_worksheet) 'my array is resized in this point ReDim my_list(1 To last_column - 1, 1) Dim i As Integer i = 1 For index= 2 To ultima_colonna my_list(i, 0) = some_worksheet.Cells(2, index).value my_list(i, 1) = index i = i + 1 Next index End Sub So, how can i write a function which returns my_list ? Something like the function below generate a mismacthing type error Public function Get_My_List as String() Get_My_List = my_list End Function and how can i call this function properly? I think that something like Dim test() as String test = Get_My_List will doesn't work

    Read the article

  • Jquery Ajax + PHP

    - by Kris.Mitchell
    I am having problems with jQuery Ajax and PHP I have my php file set up to echo the data I am gathering from a mysql database. I have verified that the database is returning something and that the string at the end of the function actually contains data. What is happening though, is that it looks like the php echo is happening before the ajax call, causing the php data to be displayed at the top of the page, and not below in proper div. I think it might have something to do with timing of the ajax and the php call, but I am not sure. So, why is the data not getting caught by the .ajax and thrown into the div? Thanks for the help! jQuery $(document).ready(function() { $.ajax({ url: "../database_functions.php", type: "GET", data: "cat=jw&sub=pi&sort=no", cache: false, success: function (html) { alert("Success!"); $('#product-list').html(html); } }); }); PHP echo "Hello World";

    Read the article

  • Convert Java String to Array

    - by Bruce
    This is a weird problem. Here is my code String reply = listen.executeUrl("http://localhost:8080/JavaBridge/reply.php); executeUrl returns as String object whatever is returned by the reply.php file. Now comes the problem. In reply.php I am returning an PHP array and reply is a String. When I do System.out.println("Reply = "+reply); I get Reply = array(2) { [0]=> string(14) "Dushyant Arora" [1]=> string(19 ) "@dushyantarora13 hi"} But reply is still a String. How do I convert it into a String array or an Array.

    Read the article

  • Visit neighbor of a position in a 2d-array

    - by Martin
    I have the following two dimensional array: static int[,] arr = new int[5, 5] { { 00, 00, 00, 01, 00 }, { 00, 00, 01, 01, 00 }, { 00, 00, 01, 01, 00 }, { 00, 00, 01, 01, 00 }, { 00, 00, 00, 01, 00 }, }; I have to a implement a method called Hit(int x, int y). When we hit a 0 in the array (i.e. Hit(0, 0), Hit(1, 1), but not Hit(3, 0)) I would like all the adjacent zeros to the zero we hit to be incremented by 10. So if I call Hit(1, 1), the array should become the following. static int[,] arr = new int[5, 5] { { 10, 10, 10, 01, 00 }, { 10, 10, 01, 01, 00 }, { 10, 10, 01, 01, 00 }, { 10, 10, 01, 01, 00 }, { 10, 10, 10, 01, 00 }, }; Any idea how I could implement that? It sounds to me like a Depth First Search/Recursive sort-of algorithm should do the job, but I haven't been able to implement it for an 2d array. Thanks for the help!

    Read the article

< Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >