string-concatenation

use both html and php in echo and href line

怎甘沉沦 提交于 2019-12-30 14:54:38
问题 I have the variable: $myvar = 'myarchive.pdf'; How can I embedd it to this: echo('<tr> <td> <a href="nextpage.php?file=trial.pdf"> download now </a> </td> </tr>'); I wonder if there is a way to do it like this: echo('<tr> <td> <a href="nextpage.php?file=".'$myvar'.> download now </a> </td> </tr>'); 回答1: You are not appending the variable to the string properly. Also you have to enclose nextpage.php?file=variable within quotes. But you are closing it before the variable name. <a href="nextpage

use both html and php in echo and href line

自作多情 提交于 2019-12-30 14:54:10
问题 I have the variable: $myvar = 'myarchive.pdf'; How can I embedd it to this: echo('<tr> <td> <a href="nextpage.php?file=trial.pdf"> download now </a> </td> </tr>'); I wonder if there is a way to do it like this: echo('<tr> <td> <a href="nextpage.php?file=".'$myvar'.> download now </a> </td> </tr>'); 回答1: You are not appending the variable to the string properly. Also you have to enclose nextpage.php?file=variable within quotes. But you are closing it before the variable name. <a href="nextpage

Concatenate two cell arrays of strings with a space in between?

北战南征 提交于 2019-12-30 11:00:18
问题 How can I concatenate: A = {'hello'; 'hi'; 'hey'} with B = {'Ben'; 'Karen'; 'Lisa'} with a space in between to get: C = {'hello Ben'; 'hi Karen'; 'hey Lisa'} Is there a fast non-looping way? 回答1: You can use strcat() , although it performs a loop: strcat(A,{' '}, B) where the blank is preserved by enclosing it within a cell. Alternatively, FEX:CStrCatStr is a mex routine which achieves a 10x speedup (depending on testing environment): CStrCatStr(A,' ', B) 回答2: A faster (albeit less elegant)

pyspark generate row hash of specific columns and add it as a new column

六眼飞鱼酱① 提交于 2019-12-30 09:53:33
问题 I am working with spark 2.2.0 and pyspark2. I have created a DataFrame df and now trying to add a new column "rowhash" that is the sha2 hash of specific columns in the DataFrame. For example, say that df has the columns: (column1, column2, ..., column10) I require sha2((column2||column3||column4||...... column8), 256) in a new column "rowhash" . For now, I tried using below methods: 1) Used hash() function but since it gives an integer output it is of not much use 2) Tried using sha2()

How to concatenate variable with string or variable in batch file

怎甘沉沦 提交于 2019-12-30 06:12:09
问题 I would like to concatenate a variable with a string. In line 7 to line 11 I try to concat !somevariable! with a string or with %%P variable. But this does not seem to work. I.e. you have file 0_1_en.pdf in current folder. The script shortcuts the name of file to first digit. Afterwards I want to create a new variable with a string for example: "GEN 0" where 0 is the !sPDFName! Complete code: 1 SETLOCAL EnableDelayedExpansion 2 for /f "delims=" %%P in ('dir /b *.pdf') do ( 3 SET "sPDFName=%%

What is the difference between VBScript's + and & operator?

久未见 提交于 2019-12-29 06:35:23
问题 On every site that talks about VBScript, the ' & ' operator is listed as the string concatenation operator. However, in some code that I have recently inherited, I see the ' + ' operator being used and I am not seeing any errors as a result of this. Is this an accepted alternative? 回答1: The + operator is overloaded, whereas the & operator is not. The & operator only does string concatenation. In some circles the & operator is used as a best practice because it is unambiguous, and therefore

String Concatenation unsafe in C#, need to use StringBuilder?

♀尐吖头ヾ 提交于 2019-12-29 01:41:08
问题 My question is this: Is string concatenation in C# safe? If string concatenation leads to unexpected errors, and replacing that string concatenation by using StringBuilder causes those errors to disappear, what might that indicate? Background: I am developing a small command line C# application. It takes command line arguments, performs a slightly complicated SQL query, and outputs about 1300 rows of data into a formatted XML file. My initial program would always run fine in debug mode.

+ operator for String in Java [duplicate]

风格不统一 提交于 2019-12-28 22:15:14
问题 This question already has answers here : How does the String class override the + operator? (7 answers) Closed 6 years ago . I saw this question a few minutes ago, and decided to take a look in the java String class to check if there was some overloading for the + operator. I couldn't find anything, but I know I can do this String ab = "ab"; String cd = "cd"; String both = ab + cd; //both = "abcd" Where's that implemented? 回答1: From the Fine Manual: The Java language provides special support

+ operator for String in Java [duplicate]

霸气de小男生 提交于 2019-12-28 22:12:11
问题 This question already has answers here : How does the String class override the + operator? (7 answers) Closed 6 years ago . I saw this question a few minutes ago, and decided to take a look in the java String class to check if there was some overloading for the + operator. I couldn't find anything, but I know I can do this String ab = "ab"; String cd = "cd"; String both = ab + cd; //both = "abcd" Where's that implemented? 回答1: From the Fine Manual: The Java language provides special support

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

旧城冷巷雨未停 提交于 2019-12-28 07:17:04
问题 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); /