string-concatenation

Group subarrays by one column, make comma-separated values from other column within groups

ε祈祈猫儿з 提交于 2019-12-28 07:16:10
问题 I have a array that looks like this: $array = [ ["444", "0081"], ["449", "0081"], ["451", "0081"], ["455", "2100"], ["469", "2100"] ]; I need to group as a new array that looks like: array ( 0 => array ( 0 => '444,449,451', 1 => '0081', ), 1 => array ( 0 => '455,469', 1 => '2100', ), ) I'd tried many scripts, but with no success. function _group_by($array, $key) { $return = array(); foreach($array as $val) { $return[$val[$key]][] = $val; } return $return; } $newArray = _group_by($array, 1); /

How should I concatenate strings?

半腔热情 提交于 2019-12-28 05:58:35
问题 Are there differences between these examples? Which should I use in which case? var str1 = "abc" + dynamicString + dynamicString2; var str2 = String.Format("abc{0}{1}", dynamicString, dynamicString2); var str3 = new StringBuilder("abc"). Append(dynamicString). Append(dynamicString2). ToString(); var str4 = String.Concat("abc", dynamicString, dynamicString2); There are similar questions: Difference in String concatenation which only asks about the + operator, and it's not even mentioned in the

Getting strings recognized as variable names in R

為{幸葍}努か 提交于 2019-12-27 18:24:04
问题 Related: Strings as variable references in R Possibly related: Concatenate expressions to subset a dataframe I've simplified the question per the comment request. Here goes with some example data. dat <- data.frame(num=1:10,sq=(1:10)^2,cu=(1:10)^3) set1 <- subset(dat,num>5) set2 <- subset(dat,num<=5) Now, I'd like to make a bubble plot from these. I have a more complicated data set with 3+ colors and complicated subsets, but I do something like this: symbols(set1$sq,set1$cu,circles=set1$num

Getting strings recognized as variable names in R

倖福魔咒の 提交于 2019-12-27 18:23:14
问题 Related: Strings as variable references in R Possibly related: Concatenate expressions to subset a dataframe I've simplified the question per the comment request. Here goes with some example data. dat <- data.frame(num=1:10,sq=(1:10)^2,cu=(1:10)^3) set1 <- subset(dat,num>5) set2 <- subset(dat,num<=5) Now, I'd like to make a bubble plot from these. I have a more complicated data set with 3+ colors and complicated subsets, but I do something like this: symbols(set1$sq,set1$cu,circles=set1$num

How to concatenate Strings in EL expression?

≯℡__Kan透↙ 提交于 2019-12-27 12:24:58
问题 I need to create a callback for <h:commandButton> while as a parameter I need to pass an argument that is string-concatenated with an external parameter id: I tried nesting an EL expression something like this: <h:commandButton ... action="#{someController.doSomething('#{id}SomeTableId')}" /> However this failed with an EL exception. What is a right syntax/approach to do this? 回答1: If you're already on EL 3.0 (Java EE 7; WildFly, Tomcat 8, GlassFish 4, etc), then you could use the new +=

How to concatenate Strings in EL expression?

北慕城南 提交于 2019-12-27 12:22:07
问题 I need to create a callback for <h:commandButton> while as a parameter I need to pass an argument that is string-concatenated with an external parameter id: I tried nesting an EL expression something like this: <h:commandButton ... action="#{someController.doSomething('#{id}SomeTableId')}" /> However this failed with an EL exception. What is a right syntax/approach to do this? 回答1: If you're already on EL 3.0 (Java EE 7; WildFly, Tomcat 8, GlassFish 4, etc), then you could use the new +=

Why is string concatenation faster than array join?

风格不统一 提交于 2019-12-27 09:53:11
问题 Today, I read this thread about the speed of string concatenation. Surprisingly, string concatenation was the winner: http://jsben.ch/#/OJ3vo The result was opposite of what I thought. Besides, there are many articles about this which explain oppositely like this. I can guess that browsers are optimized to string concat on the latest version, but how do they do that? Can we say that it is better to use + when concatenating strings? Update So, in modern browsers string concatenation is

Fastest way to convert 2D-array into char* array and copy a char into end of string

若如初见. 提交于 2019-12-25 06:55:34
问题 I'm looking for an example code or how to improve the below code (that it's very slow IMO, but it's that I can write) to the fastest way to convert an 2D-array into a char* and copy a char to it. char* join(int c, size_t arrsize, const char* arr[]) { char *buf, *tbuf, *val; size_t i, vsize, total; buf = malloc(1); for(i = total = 0; i < arrsize; ++i) { val = arr[i]; vsize = strlen(val); if((tbuf = realloc(buf, total + vsize + 2)) == NULL) { if(buf != NULL) free(buf); return NULL; } buf = tbuf

Column concatenation returns “Null” Mysql - Php

守給你的承諾、 提交于 2019-12-25 06:49:44
问题 I can able to concatenate the values using the following code $sqlselect = "UPDATE billing_details SET SRF = CONCAT(Year, ID)"; but it returns the result value as "NULL". Kindly help me to solve this issue Table Structure: Year *Varchar(5)* ID *Int(10)* SRF *Varchar(100)* Result Table: Year Id SRF A 1 NULL A 2 NULL A 3 NULL 回答1: MySql CONCAT function is return NULL if any argument value if null value, see blow SELECT COCAT(NULL, 1) OR SELECT COCAT(1, NULL) >NULL If you want to keep other

Column concatenation returns “Null” Mysql - Php

二次信任 提交于 2019-12-25 06:49:15
问题 I can able to concatenate the values using the following code $sqlselect = "UPDATE billing_details SET SRF = CONCAT(Year, ID)"; but it returns the result value as "NULL". Kindly help me to solve this issue Table Structure: Year *Varchar(5)* ID *Int(10)* SRF *Varchar(100)* Result Table: Year Id SRF A 1 NULL A 2 NULL A 3 NULL 回答1: MySql CONCAT function is return NULL if any argument value if null value, see blow SELECT COCAT(NULL, 1) OR SELECT COCAT(1, NULL) >NULL If you want to keep other