w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
$_POST is returning just 'Array' as string and i am posting an Array
I'm pretty sure that <input type="checkbox" name="om[1]" value="10"> is not the same as $_POST['om'][1] The one in the form is an array with a string-type index "1", while in the $_POST var you're accessing the first element of $_POST['om']. So you'll either have to use something else than integers in the HTML form or access the values by using $_POST['om']['1'].

Categories : PHP

Returning single String from array
You need to change your initialisation block to static initialisation block. static { questions[0] = "Some question1"; questions[1] = "Some question2"; } If you won't create new instance of Database class like: Database db = new Database(); dynamic initialisation block won't be called. This is reason why you need to use static initialisation block that is called with class.

Categories : Java

Ruby String variable returning true for .is_a?(Array)
def do_stuff(x) x = x.lines.to_a if x.is_a? String x end data = [ "hello world", [1, 2, 3] ] data.each do |item| p do_stuff item end Now, with unless: def do_stuff(x) unless x.is_a?(Array) x = x.lines.to_a end x end data = [ "hello world", [1, 2, 3], ['a', 'b'] ] data.each do |item| p do_stuff item end --output:-- ["hello ", "world"] [1, 2, 3] ["a", "b"] But it makes more sense to check for a String object before calling a String method on the object than checking for not an Array.

Categories : Ruby

Making section in UITableView closed(with 0 cells) after scrolling away and returning to it
You can implement the scroll view delegate methods and use them to check the scroll position (contentOffset) and / or the visible cells (indexPathsForVisibleRows). Once you know that you can collapse any sections that are no longer visible. You should probably use one of the scroll methods that means the scrolling has stopped (maybe scrollViewDidEndScrollingAnimation:) because changing the table view content size (which changing the number of rows will do) during a scroll animation could cause it to stop abruptly.

Categories : IOS

Saving contents of String Array List when moving to a new activity and returning to the previous one
You should use PersistentState of app (SharedPreferences) So make the onPause() method on your activity and there save SharedPreferences SharedPreferences settings = getSharedPreferences("key", MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.put.... Then onCreate check for SharedPreferences.contains("key"); and reload data from there with SharedPreferences settings = getSharedPreferences("key", MODE_PRIVATE); settings.get...

Categories : Java

JSON returning multiple columns, but all values as single string. How do I get matching key-value from array?
For the JSON: {"COLUMNS":["ABC","DEF","GHI"],"DATA":[[11,27,4]]}" The property DATA is an array of arrays. Consider it like this: DATA = [a, b, c], where a, b and c are variables. The thing is that your a is another array, just as DATA is. This way DATA[0], the first element of the DATA array, is an array. How do I get DATA[0], which should be 11? The value you want is in: DATA[0][0]: Because: DATA[0] -> [11,27,4] Then: DATA[0][0] -> 11 DATA[0][1] -> 27 DATA[0][2] -> 4

Categories : Javascript

Returning a Unicode string vs. Returning a normal string encoded as UTF-8?
UTF-8 is an encoding of the entire Unicode character set. It is backwards compatible with ASCII. For characters outside the ASCII set, multibyte encodings are used. All ASCII strings are Unicode strings. All Unicode strings are not ASCII strings.

Categories : Python

given string of braces both open and closed tell if it's a valid string
If n is the length of the string, the algorithm complexity can't be less than O(n), because if there is any character the algorithm didn't check, it can't be sure of whether the character is a brace or not. So, it can't be less than O(n).

Categories : Algorithm

Is it better to make a method for returning a string from an Enum? or to have an extra string variable to hold the string value?
Your getSize() method can be reduced to: public string getSize() { return pSize.ToString(); } Given that the method is really this simple, it seems rather pointless to provide this as a separate method. If you simply expose pSize as a property (or read-only property) the user can simply call ToString() on that property: public EnumSize Size { get { return this.pSize; } }

Categories : C#

Finalizing a Cursor that has not been deactivated or closed or database not closed error
When you are done with the cursor, you need to call Cursor.close(). Leaving it not closed leads to memory leaks. E.g.: Cursor cursor = null; try { cursor = getContentResolver().query(myUri, MY_PROJECTION, null, null, null); if (cursor != null && cursor.moveToFirst()) { // moar code } } finally { if (cursor != null) { cursor.close(); } }

Categories : Android

Returning an array and storing into another array, creating a multidimensional array
My function generatePrice() returns an array, No it doesn't, it returns undefined. XHR is asynchronous, see How to return the response from an AJAX call?. priceArray = generatePrice(resultArr[ctr].symbol); I can't seem to store it in another array You didn't attempt to do so, you just stored the result of every call in the priceArray variable - instead of in a property of the array. Use priceArray[ctr] = generatePrice(resultArr[ctr].symbol); // or priceArray.push( generatePrice(resultArr[ctr].symbol) );

Categories : Javascript

Application gets closed when terminal is closed, how to stop this?
Use nohup to prevent child processes from being killed when the terminal closes. spawn nohup /usr/bin/firefox https://www.google.com/ I assume there's more to the script, since there's no need to use Expect just to start firefox.

Categories : Python

Determine last character in PHP string, replacing and returning the string with new characters
this is wrong if ($last_char != "." || "!" || "?") because "!" and "?" are non-zero, so though the first condition is false the next 2 conditions are always true. As a result the whole statement is true. try if ($last_char != "." && $last_char!="!" && $last_char!="?") {

Categories : PHP

String Split sql function only returning first word in string
Your function is returning a leading blank in front of Andy. You should use LTRIM function to remove it. Either in function, on insert into @tbl: INSERT @tbl (string) VALUES (LTRIM (substring(@list, @pos + 1, @valuelen))) or when you call function: SELECT LTRIM(string) FROM [dbo].[func_ParseString] ('Dan, Andy')

Categories : SQL

How to solve returning an array into an empty array Java
if (ship[z].GetLocation() != 0) ship[z] is empty (null), so that's why you get the error. You need to fill yout ship array first. The important thing is: ship array stores references not objects, so that's why you need to fill it first. So Ship[] ship = new Ship[10] stores 10 Ship references (which starts as null), the actual Ship objects you need to assign by yourself.

Categories : Java

How to Convert Array into String in HTML Form? [Notice: Array to string conversion?]
$_FILES["files"]["tmp_name"] is the array of the files you are receiving So you need to do:- move_uploaded_file($_FILES["files"]["tmp_name"][$key], "upload/products/" . $random_name); Or you are receiving current temp name in the $tmp_name so you can use:- move_uploaded_file($tmp_name, "upload/products/" . $random_name);

Categories : PHP

how do i convert Dictionary string string to array of key value pair of string and string using linq and c#
try below , you may need to change the set properties of new object accordingly ArrayOfKeyValueOfstringstringKeyValueOfstringstring[] array = valuePairs.Select(pair => new ArrayOfKeyValueOfstringstringKeyValueOfstringstring(){ Key= pair.Key, Value= pair.Value}).ToArray();

Categories : C#

Returning Entire Sub-Array (Containing Maximum Value) From Array
function max_dist($array) { $maxIndex = 0; $index = 0; $maxValue = $array[0]['distance']; foreach( $array as $i){ if($i['distance'] > $maxValue){ $maxValue = $i['distance']; $maxIndex = $index; } $index++; } return $array[$maxIndex]; } $jump = max(array_map("max_dist", $jumps)));

Categories : PHP

How to draw closed spline 3D (closed curve 3d) through unordered list of points3D. How to arrange points3D?
It sounds like you're looking for the Concave Hull of the data set. Unfortunately, I don't know of any pre-canned algorithms, but the link references a paper that another developer was starting from, as well as some sample code, so maybe that'll help you in the right direction.

Categories : C#

Sort a php array returning new array
Would you be able to do this? $some_mixed_array = array( 998, 6, 430 ); function custom_sort( $array ) { // Sort it asort($array); // return sorted array return $array; } custom_sort( $some_mixed_array ); // returning: array( 6, 430, 998 ) This would also solve your issue: $some_mixed_array = array( 998, 6, 430 ); echo '<pre>'.print_r($some_mixed_array, true).'</pre>'; asort($some_mixed_array); // <- BAM! // returning: array( 6, 430, 998 ) echo '<pre>'.print_r($some_mixed_array, true).'</pre>';

Categories : PHP

Passing C# structure with string array to c++ function which accepts void * for c# structure and char** for c# string array
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public String[] Parameters; is an inline array. The C++ declaration that matches is: char* Parameters[2]; But you are trying to match it to: char** Parameters; and that's completely different. You will need to marshal this by hand. In the C# struct declare Parameters to be IntPtr. Then allocate native memory with Marshal.AllocHGlobal to hold an array of pointers. And then populate those pointers with pointers to your strings. [StructLayout(LayoutKind.Sequential)] public struct TestInfo { public int TestId; public IntPtr Parameters; } static void Main(string[] args) // no need for unsafe { TestInfo testInfo; testInfo.TestId = 1; testInfo.Parameters = Marshal.AllocHGlobal(2*Marshal.SizeOf(typeof(IntPtr)));

Categories : C#

The underlying connection was closed: The connection was closed unexpectedly wcf service
The first thing i will do is, instead of returning the full list of candidates i will return an empty list. If that works fine, then it is very clear that the size of the data is a problem. To modify the size play with your binding parameters.

Categories : Wcf

Function taking an array filled with structures, and returning a bigger array with the same structures
You can't reassign friends like that since it's not a pointer, it's an array. Even if you could, what you're doing isn't safe since GrowArray just creates a new array on the stack which will be destroyed when the function returns. You should either use new and delete to create and destroy the arrays (you can then then pass them around as pointers), or preferably, use std::vector which handles all this stuff for you.

Categories : C++

PHP SQL Array not returning anything
I assume lead_id is a field in DB so you don't need quotes for it: AND lead_id = '$entry_id' You're also going wrong by putting variables directly into the query, you make your app vulnerable to SQL injections. consider using prepared statements.

Categories : PHP

string.contains is always returning true
You used assignment operator in the if statement instead of equality. It should be like this: if(check == true){ teststring[i] = storestrings[i]; //System.out.print(storestrings[i]); } or simply if (check) { teststring[i] = storestrings[i]; //System.out.print(storestrings[i]); } In your code, when it reached check = true in the if statement, it assigns true to the check variable and returns true so the if condition always evaluates to true.

Categories : String

String not returning correctly
this statement return wkflow_param; should come after the ending of foreach (var wf_item in tb.Children.WorkflowRefCollection)

Categories : C#

Returning std::vector, but sometimes only
If this in an error condition, then you should throw an exception. If an empty list is considered normal operation, then return an empty vector. The answer will depend heavily on your application.

Categories : String

xsl extensionFunctions returning fo string
I think you should be able to use xsl:copy-of ... as in: <xsl:copy-of select="test:MyMethode(.)"/> or possibly your "string" result is being escaped, so try: <xsl:value-of select="test:myMethode(.)" disable-output-escaping="yes"/> I have used both methods to return inline SVG into XSL FO to be interpreted as nodes and not a string. I think it really depends on what MyMethode() is returning as a data type.

Categories : Java

Error while trying to place string array into string array
Your code really needs refactoring, dont use arrays of strings - use vector-s of strings: std::vector<std::string> parse(string str,int from){ std::vector<std::string> data(6); .... .... return data; } int main(){ std::vector<std::string> data=parse(str,18); }

Categories : C++

Convert System.String array into php string array
Isn't "implode" what you're looking for in php? Something like this? And to use it : $string = implode("",$yourArray);

Categories : C#

COUNT returning array?
if $connect is mysqli object: $total = $connect->query(" SELECT COUNT(*) AS `count` FROM photos WHERE gallery = '$row[id]' ")->fetch_assoc(); // $total['count'] Notice: Use PDO library and param binding to prevent sql injections.

Categories : PHP

webservice not returning a array
Assuming your data is like the following: $return = '<?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org /2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <GETOfertasAereasResponse xmlns="http://tempuri.org/"> <GETOfertasAereasResult>Some result content</GETOfertasAereasResult> </GETOfertasAereasResponse> </soap12:Body> </soap12:Envelope>'; Try this: $obj = new SimpleXMLElement($return); $body = $obj->children('soap12', true)->Body->children(); $content = (string) $body->GETOfertasAereasResponse->GETOfertasAereasResult; var_dump($content);

Categories : PHP

Returning an integer array
Try: int foo(int arrayBar[]) or int foo(int* arrayBar) or int* foo(int arrayBar[]) If those don't work, make sure your pointer is at the beginning of the array. Source: c++ return array in a function

Categories : C++

2D array of Doubles returning 0
Your typecast is in the wrong place. Your expression (double)(1/(i+j-1)) will almost always be 0 due to integer division. You will get 1 out when i == j == 1. You probably want: 1.0/(i+j-1)

Categories : C++

D3 - Returning the whole array with the max count
This isn't really d3 specific, but you could just do: var highest = pieData.reduce(function(highest, item) { return item.count > highest.count ? item : highest; }, pieData[0]);

Categories : Javascript

Returning an Array using Firebase
The problem occurs in getPosts(). It pushes a promise into your array inside an async function--that won't work since q.all is called before the promise objects have been added. Also, child_added is a real-time event notification. You can't use that as a way to grab "all of the data" because there is no such thing as "all"; the data is constantly changing in real-time environments. FirebaseIndex is also using child_added callbacks internally, so that's not going to work with this use case either. You can grab all of the posts using the 'value' callback (but not a specific subset of records) as follows: function getPosts() { var def = q.defer(); Firebase.child('users').once('value', function(snap) { var records = []; snap.forEach(function(ss) { records.push( ss

Categories : Node Js

php array not returning full out put
You're only reading one block of 4096 characters from your stream. if your folder list is longer than this you'll lose the rest. You need something like this: stream_set_blocking($stream, true); $item = ""; // continue reading while there's more data while ($input = fread($stream,4096)) { $item .= $input; } $items = explode(" ", $item); print_r($items);

Categories : PHP

Returning an array from the model
App.Player.find() returns a promise, and therefore you should wait until your records are fully loaded before doing operations on them. From your question it's not entirely clear how you player objects do look like. But to get to your players, and especially to your player's properties, you could do something like: var playerList = App.Player.find().then(function (result) { // This callback will fire when array is loaded // and this is the correct way to get to the records result.objectAt(0).get('name'); // assuming "name" is a property of your model // here you can then loop over your obejcts result.forEach(function(item) { console.log(item.get('name')); }); }); Hope it helps.

Categories : Ember Js

Returning an Array from a file
You should just store the array as ... an array, like so: file_put_contents('myfile.txt', '<?php return ' . var_export($array, true) . '; ?>'); Then, to read: $array = include 'myfile.txt'; See also: var_export()

Categories : PHP

Returning String[] from controller using Ajax
you can return JSON with whatever parameters you may need. Create an action like the one bellow public JsonResult AjaxHandler(string SomeParam) { return Json(new{ someOtherDataId = 3, stringArray = new string[] {"one", "two", "three", "four"} }, JsonRequestBehavior.AllowGet); }

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.