sometext( [key] = value which content number and alphabates )
from above,i want only value part by using explode function for only one time.Is it possible.
or any other function is present in php.
I using php's str_replace function to replace some text. Example below.
str_replace("{x+{\$v}}", "{x-{\$v}}", $this->introtext);
str_replace('{x+{\$v}}', '{x-{\$v}}', $this->introtext);
In first case it replace text, but in second case it is not doing so. What is difference between two?
I am reading Effective C# by Bill Wagner. In Item 14 - Minimize Duplicate Initialization Logic, he shows the following example of using the new optional parameters feature in a constructor:
public MyClass(int initialCount = 0, string name = "")
Notice that he used "" instead of string.Empty. He comments:
You'll note [in an example above] that the second constructor specified "" for the default value on the name parameter, rather than the more customary string.Empty. That's because string.Empty is not a compile-time constant. It is a static property defined in the string class. Because it is not a compile constant, you cannot use it for the default value for a parameter.
If we cannot use the string.Empty static in all situations, then doesn't that defeat the purpose of it? I thought that we would use it to be sure that we have a system-independent means of referring to the empty string. Is my understanding wrong? Thanks.
Let's say this is the code:
a="xyz"
g="abcd " & a
So now the value of g is abcd xyz. I want quotes around xyz i.e g should be abcd "xyz"
How do I do that?
My html:
<script type="text/javascript">
$(function() {
$("#bt1").click(function() {
var f = $("#form1");
var formData = f.serialize();
alert(formData);
});
});
</script>
<div id="div1">
<form id="form1" action="/Home/Test1" method="post" name="down">
<div id="div2">
<input id="input1" type="text" value="2" />
</div>
</form>
</div>
<input type="submit" id="bt1" />
When I fire up the click event, formData is empty. I'm using jQuery 1.4.2.
I have a lotus view that stores a number. I need to perform some math against the value, but I am having a lot of problems getting the types to match up.
doc.numOfGold = numGold
and CInt(doc.numOfGold) = numGold
and CInt(doc.numOfGold) = CInt(numGold)
and doc.numOfGold = CInt(numGold)
all return type mismatch. I've tried changing the column properties to treat it as a decimal, with no better luck.
Any thoughts?
Thanks!
Some people using look-alike Unicode symbols to replace English characters to test the internationalization, e.g. "Test" is replaced as "Test". Is there a wellknown name for this language/culture? Are there utils, keyboard layouts, translation tools for this "language"?
In the code below, Pages is defined as
public SortedDictionary<DateTime, float[]> Pages { get; set; }
I am trying to dynamically increase the size of this array. Can anyone tell how to increase the sized of the innermost float[]?
var tt = currentContainer.Pages[dateTime];
Array.Resize<float>(ref tt, currentContainer.Pages.Count + 1);
Fail 1
I tried the following code and get index out of range exception
SortedDictionary<DateTime, float[]> Pages = new SortedDictionary<DateTime,float[]>();
float[] xx = new float[1];
xx[0] = 1;
DateTime tempTime = DateTime.UtcNow;
Pages.Add(tempTime, xx);
var tt = Pages[tempTime];
Array.Resize<float>(ref tt, Pages.Count + 1);
Pages[tempTime][1] = 2;
Fail 2
The following gives a compile time error (property, index, or dynamic member can't be used as a ref value)
SortedDictionary<DateTime, float[]> Pages = new SortedDictionary<DateTime,float[]>();
float[] xx = new float[1];
xx[0] = 1;
DateTime tempTime = DateTime.UtcNow;
Pages.Add(tempTime, xx);
var tt = Pages[tempTime];
// The line below is different from Fail 1 above ... compile time error
Array.Resize<float>(ref Pages[tempTime], Pages.Count + 1);
Pages[tempTime][1] = 2;
Question
What is the most performant answer to resize this array?
Would the answer change if it's likely that the final size will be 100-200 floats or 700-900 floats?
What if I change my allocation size from +1 to +128? .. or larger?
The conversion of a char data type to a DateTime data type resulted in an out-of-range DateTime value.
The statement has been terminated.
Please give me most possible answers
ALTER PROCEDURE [dbo].[attendance_updatebyemployee_id]
@Employee_id int,
@AtDate datetime,
@FNLogged bit,
@ANLogged bit,
@LogTime varchar(10),
@LogOuttime varchar(10)
AS
BEGIN
SET NOCOUNT ON;
update Mst_Attendance set FNLogged=@FNLogged,
ANLogged=@ANLogged,LogTime=@LogTime,LogOuttime=@LogOuttime
where EmployeeId=@Employee_id and Atdate= @AtDate
END
I am writing a app in .NET which will generate random text based on some input. So if I have text like "I love your {lovely|nice|great} dress" I want to choose randomly from lovely/nice/great and use that in text. Any suggestions in C# or VB.NET are welcome.
I need to check if a key exists and return its value if it does.
Key can be an array with subkeys or endkey with a value.
$_SESSION['mainKey']['testkey'] = 'value';
var_dump(doesKeyExist('testkey'));
function doesKeyExist($where) {
$parts = explode('/',$where);
$str = '';
for($i = 0,$len = count($parts);$i<$len;$i++) {
$str .= '[\''. $parts[$i] .'\']';
}
$keycheck = '$_SESSION[\'mainKey\']' . $str;
if (isset(${$keycheck})) {
return ${$keycheck};
}
// isset($keycheck) = true, as its non-empty. actual content is not checked
// isset(${$keycheck}) = false, but should be true. ${$var} forces a evaluate content
// isset($_SESSION['mainKey']['testkey']) = true
}
What am I doing wrong ?
Using PHP 5.3.3.
I'm having a coloumn name with varchar field that holds some folder path like "C:\Program Files\Internet Explorer\en-US" .I need to update the root folder name(Program files to profilesNew).Can anyone please help.
I tried with a query
declare @val as varchar(100)
set @val='C:\Program Files\Internet Explorer\en-US'
select substring(@val,charindex(':\',@val),charindex('\',@val))
but not getting the exact answer
C:\Program FilesNew\Internet Explorer\en-US
I have a php variable that comes from a form that needs tidying up. I hope you can help.
The variable contains a list of items (possibly two or three word items with a space in between words).
I want to convert it to a comma separated list with no superfluous white space. I want the divisions to fall only at commas, semi-colons or new-lines. Blank cannot be an item.
Here's a comprehensive example (with a deliberately messy input):
Variable In: "dog, cat ,car,tea pot,, ,,, ;;(++NEW LINE++)fly, cake"
Variable Out "dog,cat,car,tea pot,fly,cake"
Can anyone help?
Hi. First I have to say: Happy Christmas to All!
I'm starting learning classes in PHP. I coded that:
class User {
function getFbId($authtoken) {
}
function getFbFirstName ($authtoken) {
}
}
What I want to do is something like that: $user=new User($authtoken); And pass the $authtoken to the class. It's possible to define that when starting the class. It's possible to retrive that value inside a function of that class?
I'm trying to print strings in one line.
I've found solutions but they don't works with windows correctly.
I have text file contains names and I want to print them like this
name=john then change john to next name and keep name=, I've made this code but didn't work correctly with windows:
op = open('names.txt','r')
print 'name=',
for i in op.readlines():
print '\r'+i.strip('\n')
thank you for your time
Note: I have read all of the related PHP, UTF-8, character encoding articles that are usually suggested, but my question relates to data inserted before I applied such techniques. I am wishing to retrospectively fix all character encoding problems.
Now all connections are set as utf8 using PDO.
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
Unfortunately, a large amount of data was inserted that is of questionable encoding before I had implemented correct character encoding practices. As displayed by:
$sql = "SELECT name FROM data LIMIT 3";
foreach ($pdo->query($sql) as $row)
{
$name = $row['name'];
echo $name . "\n";
echo utf8_encode($name) . "\n";
echo utf8_decode($name) . "\n";
echo htmlspecialchars($name, ENT_QUOTES, 'UTF-8') . "\n";
echo htmlspecialchars(utf8_encode($name), ENT_QUOTES, 'UTF-8') . "\n";
echo htmlspecialchars(utf8_decode($name), ENT_QUOTES, 'UTF-8') . "\n";
echo '<hr/>';
}
Which produces:
AntonÃÂn Dvořák
AntonÃÆÃÂn DvoÃâ¦Ãâ¢ÃÆÃ¡k
Anton??n Dvo??????¡k
AntonÃÂn Dvořák
AntonÃÆÃÂn DvoÃâ¦Ãâ¢ÃÆÃ¡k
----------
Ô±Ö€Õ¡Õ´ Ô½Õ¡Õ¹Õ¡Õ¿Ö€ÕµÕ¡Õ¶
ñÃâ¬Ã¡Ã´ ýáùáÿÃâ¬ÃµÃ¡Ã¶
????? ??????????
Ô±Ö€Õ¡Õ´ Ô½Õ¡Õ¹Õ¡Õ¿Ö€ÕµÕ¡Õ¶
ñÃâ¬Ã¡Ã´ ýáùáÿÃâ¬ÃµÃ¡Ã¶
----------
Tiësto
Tiësto
Tiësto
Tiësto
Tiësto
Tiësto
----------
When removing 'SET NAMES utf8' with PDO it produces the data:
AntonÃn DvoÅák
AntonÃÂn DvoÃÂák
Antonín Dvorák
AntonÃn DvoÅák
AntonÃÂn DvoÃÂák
Antonín Dvorák
----------
???? ?????????
Ô±ÖÕ¡Õ´ Ô½Õ¡Õ¹Õ¡Õ¿ÖÕµÕ¡Õ¶
???? ?????????
???? ?????????
Ô±ÖÕ¡Õ´ Ô½Õ¡Õ¹Õ¡Õ¿ÖÕµÕ¡Õ¶
???? ?????????
----------
Tiësto
Tiësto
Ti?sto
Tiësto
Tiësto
----------
And here is a dump of the database rows concerned:
DROP TABLE IF EXISTS `data`;
CREATE TABLE IF NOT EXISTS `data` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(80) NOT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`(10)),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0;
INSERT INTO `data` (`id`, `name`) VALUES (0, 'AntonÃÂn Dvořák'), (1, 'Ô±Ö€Õ¡Õ´ Ô½Õ¡Õ¹Õ¡Õ¿Ö€ÕµÕ¡Õ¶'), (2, 'Tiësto');
The 3rd and 6th lines of the 3rd row "Tiësto" are then correctly echoed. I'm just unsure what is the best way to correct encodings/detect the encodings of bad strings and correct, etc.
Hi everyone
I want to make a quiz, I want to have to output an array of questions after a form is submitted.
I know to use a bean I think but how would I do this?
Thanks
I have an array, like
var acronyms = {
'NAS': 'Nunc ac sagittis',
'MTCP': 'Morbi tempor congue porta'
};
I need to find first match of each acronym and wrap around with tag via jQuery.
E.g.
<div id="wrap">NAS dui pellentesque pretium augue. MTCP pellentesque pretium augue. NAS ac ornare lectus MTCP nec.</div>
becomes
<div id="wrap"><acronym title="Nunc ac sagittis">NAS</acronym> dui pellentesque pretium augue. <acronym title="Morbi tempor congue porta">MTCP</acronym> pellentesque pretium augue. NAS ac ornare lectus MTCP nec.</div>
Thanks.
i'm wondering why doesn't this work ?
it gives me the exception that the "File Format Is Not Valid"
richTextBoxPrintCtrl1.Rtf = richTextBoxPrintCtrl2.Rtf.Insert(richTextBoxPrintCtrl1.SelectionStart, myString);
I am trying to add a .html suffix at the end of all strings supplied by the user before it is entered into the database. Here's my code so far:
strtolower(str_replace(" ", "_", $postTitle));
The above takes the title of the post the user it trying to make, turns it to lower case, replaces all white spaces with underscores and makes it ready to be entered into a database column called post_url.
I just need it to do one more thing and that's to add a .html at the end of each post url. What is the function to do this?
Strings in JavaScript are immutable. Across the web and here on Stack Overflow as well, I came across the Array approach to concatenate strings:
var a = [];
a.push(arg1,arg,2....);
console.log(a.join(''));
I know that this approach is better than the simple
console.log(arg1 + arg2 +.....);
for reasons of skipping creating intermediate objects but how does it fair better against :
arg1.concat(arg2,arg3.....);
My send mail task works fine for email ids like [email protected] but it throws error for email ids like [email protected].
is there any way i can make it work for such ids also?
Thanks.
In actionscript an object's property can be accesses in this way:
object["propertyname"]
Is something like this possible in c#, without using reflection?
how do you append an additional url parameter to a link in your google search results? is it possible to do this within the style sheet?
for example i have domain.com/result.htm - i want to change the link to domain.com/result.htm?param=1
thank you