add

Add new data into PHP JSON string

拜拜、爱过 提交于 2019-11-28 11:11:53
I have $data as JSON encoded data and I have this string: $new_data = "color:'red'"; that needs to be added to $data so that I can read it from it as a json string. How can I achieve this ? you need to json_decode($data) first, then add the new key/value, and json_encode() it. Ben I was just searching for the solution to this and stumbled across this question (already one year old). The answers provided so far were not very helpful to me. So, hopefully this helps the next person. The answer I was looking for was $json = json_decode($data,true); which returns the result in an array structure,

unstaged files gone after git reset --hard

旧时模样 提交于 2019-11-28 11:11:36
I tried the git reset --hard HEAD@{n} from git reflog and I lost everything with my current unstaged files :'( the unstaged files is the last git add I did, before then I tried git reset to the last git commit . And all my files gone, I can't go back to the git add before last commit :'( Andrew C It's not clear if you lost files in your working directory, or files in the index. You say you lost your "unstaged files", but then you mention you might have run "git add". "unstaged files" are lost for good. Staged files can be recovered with git fsck --full --unreachable --no-reflog For each file

How to add same view to parent multiple times by inflating it only once

最后都变了- 提交于 2019-11-28 10:40:28
I have a LinearLayout with vertical orientation as parent, I want to add some view programmatically multiple times to this parent. Right now I am inflating the child every time getting new references to every UI element before adding to parent. This doesn't seem to be very efficient, is there any better way of doing this. Current code I am using is below, If I inflate only once before for loop I get runtime error "he specified child already has a parent. You must call removeView() on the child's parent first." LayoutInflater inflator = LayoutInflater.from(getBaseContext()); LinearLayout

Why can I add characters to strings but not characters to characters?

谁说我不能喝 提交于 2019-11-28 09:58:09
问题 So I wanted to add a character to a string, and in some cases wanted to double that characters then add it to a string (i.e. add to it itself first). I tried this as shown below. char s = 'X'; String string = s + s; This threw up an error, but I'd already added a single character to a string so I tried: String string = "" + s + s; Which worked. Why does the inclusion of a string in the summation cause it to work? Is adding a string property which can only be used by characters when they're

Adding two DateTime objects together

纵饮孤独 提交于 2019-11-28 09:50:45
Is there any better way to add one DateTime object to another one, than this: DateTime first = new DateTime(2000, 1, 1); DateTime second = new DateTime(11, 2, 5, 10, 10, 11); DateTime result = first.AddYears(second.Year); DateTime result = first.AddMonths(second.Month); ... and so on... In this example I'd like to get DateTime(2011, 3, 6, 10, 10, 11) EDIT After a intensive brainstorm it seems to there's no different way, but to facilitate it can be boxed inside additional class and operator+ just like in JonSkeet's answer It doesn't make sense to add two DateTime values together. If you want

Add numbers in c#

拥有回忆 提交于 2019-11-28 09:24:23
问题 i have a numerical textbox which I need to add it's value to another number I have tried this code String add = (mytextbox.Text + 2) but it add the number two as another character like if the value of my text box is 13 the result will become 132 回答1: String add = (Convert.ToInt32(mytextbox.Text) + 2).ToString(); You need to convert the text to an integer to do the calculation. 回答2: The type of mytextbox.Text is string . You need to parse it as a number in order to perform integer arithmetic,

Add text to textarea - Jquery

蓝咒 提交于 2019-11-28 08:52:28
How can I add text from a DIV to a textarea? I have this now: $('.oquote').click(function() { $('#replyBox').slideDown('slow', function() { var quote = $('.container').text(); $('#replyBox').val($('#replyBox').val()+quote); // Animation complete. }); }); Just append() the text nodes: $('#replyBox').append(quote); http://jsfiddle.net/nQErc/ That should work. Better if you pass a function to val : $('#replyBox').val(function(i, text) { return text + quote; }); This way you avoid searching the element and calling val twice. 来源: https://stackoverflow.com/questions/7058864/add-text-to-textarea

Insert page into existing PDF using itextsharp

孤街醉人 提交于 2019-11-28 07:51:44
问题 We are using itextsharp to create a single PDF from multiple PDF files. How do I insert a new page into a PDF file that has multiple pages already in the file? When I use add page it is overwriting the existing pages and only saves the 1 page that was selected. Here is the code that I am using to add the page to the existing PDF: PdfReader reader = new PdfReader(sourcePdfPath); Document document = new Document(reader.GetPageSizeWithRotation(1)); PdfCopy pdfCopy = new PdfCopy(document, new

JList add/remove Item

♀尐吖头ヾ 提交于 2019-11-28 07:30:35
问题 Hi I have to pick an element from a JList to another, removing it from the first The method I've created inserts only one element, overwriting the last one and doesn't remove the selected item from the first JList Here's the code: First list private javax.swing.JList listaRosa; Populated by this method: private void visualizzaRosaButtonvisualizzaRosa(java.awt.event.ActionEvent evt) { // TODO add your handling code here: visualizzaSquadraSelezionata(); String fileSquadra; fileSquadra =

How to add text to an existing div with jquery

你。 提交于 2019-11-28 04:49:58
I want to add text to an existing div, when I click the Button with the id #add. But this is not working. Here my code: $(function () { $('#Add').click(function () { $('<p>Text</p>').appendTo('#Content'); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div id="Content"> <button id="Add" /> </div> I hope you can help me. bretterer You need to define the button text and have valid HTML for the button. I would also suggest using .on for the click handler of the button $(function () { $('#Add').on('click', function () { $('<p>Text</p>').appendTo('