|
Let us say if I have a hash like this:
$data = { 'key1' => { 'key2' => 'value1' }, 'key3' => { 'key4' => { 'key5' => 'value2' } }, };
Now, how can I replace the the key 'key5' with some other key name say 'key6'? I know how to loop through...
Started by John on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
You can't replace it, but you can make a new key easily, and then delete() the old one:
$data-> if you don't mind a little clutter:
sub hash_replace (\%$$) { $_[0]->{$_[2]} = delete $_[0]->{$_[1]}; # thanks mobrule! }
Then....
|
|
Currently I have a the following way of retrieving data from my DB:
$school->get('studentCount');
I required a shortcut to access these fields within the page and so came up with a format like this:
<p>Blah blah blah [[studentCount]]</p>...
Started by J-P on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Function would be preg_replace
http://us2.php.net/preg-replace
Well you ....
replace with arrays but I wanted the key ('[[...]]') to directly tie in with the 'get' method, so what is in between into your ->get() function.
|
|
I have a large string which is a collection of key (space)+ value , i.e key followed by one or more space and then value . Now i need to change the value of a particular key using sed, awk, grep etc. in unix environment.
eg. of string: -Key1 Value1 -Key...
Started by Gautam Borad on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Try this
#!/bin/bash read -p "What is your key?: " key read -p "What is new value?: " value echo "-Key1 Value1 -Key2 Value2 -Key3 Value3" | awk -vk="$key" -vv="$value" -F"-" ' { for(i=1;i<=NF;i++){ if($i ~ k){....
Should do it.
|
Ask your Facebook Friends
|
Can anyone help me decode why this doesnt work?
$cssid = preg_replace("/'/", "", $cssid);
Trying to strip the single quote marks from some html...
Thanks! H
EDIT This is the full function - it's designed to rebuild the Drupal menu using images, and it...
Started by hfidgen on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
If str_replace("'","") doesn't work
And for the apostrophe replacement....
But why don’t you use str_replace as you’re replacing a fixed string?
$cssid = str_replace("'", "", $cssid);
escape the single quote.
Your code looks fine.
|
|
I have a list of tuples eg. [{1,40},{2,45},{3,54}....{7,23}] where 1...7 are days of the week (calculated by finding calendar:day_of_the_week()). So now I want to change the list to [{Mon,40},{Tue,45},{Wed,54}...{Sun,23}]. Is there an easier way to do...
Started by Sushant on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
...or using a different syntax:
[{httpd_util:day(A), B} || {A,B} <- L]
where L = [{1,40},{2,45},{3,54}...... .
Lists:map(fun({A,B}) -> {httpd_util:day(A),B} end, [{1,40},{2,45},{3,54},{7,23}]).
Use map and a handy tool from the httpd module .
Simple.
|
|
Dear friends,
The keyboard of my laptop presents a failture on a specific character.
Unnafortunatelly, it is used on logon.
Does anybody know how to setup an alternative to replace it ?
( as an <CTRL><ALT> combination )
+++
Started by andre_teprom on
, 11 posts
by 6 people.
Answer Snippets (Read the full thread at edaboard):
Thanks guys, but unafortunatelly, no answer was perceived from Laptop, even pressing the key for a long.
Maintain the alt key, and press the ascii code of the character you want to type on the numeric.
|
|
I just finished a DIY (on the e38 Bimmerforum.com) on how to replace the rubber key pads in the old style keys.
If anyone is interested in how it's done...just click this link: http://forums.bimmerforums.com/forum....php?t=1548798
I replaced the one on...
Started by QSilver7 on
, 7 posts
by 6 people.
Answer Snippets (Read the full thread at bimmerfest):
) & converting the old-style 1996-2000 "square" key to a diamond key ( 1 ) & how to replace the rubber key to a diamond key ( 1 ) & how to replace the rubber key pads in the old style keys ( 1 )....
|
|
I have some text, something like this:
Paragraphs of text (SOME KNOWN TEXT)Unknown Text(SOME OTHER KNOWN TEXT) Some additional paragraphs of text
What I want is to keep the Unknown Text , but get rid of the ( SOME KNOWN TEXT) and (SOME OTHER KNOWN TEXT...
Started by OneNerd on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
The first argument is the set of keys to replace, the second argument is what to ....
If the two texts truly are known, you can do this:
$result = str_replace(array('(SOME KNOWN TEXT is better performance than a regular expression.
|
|
I have a Set of keys and a List of key/value pairs. The values are of the form Long,BigInteger.
// key/values pairs: Long,BigInteger List<Object[]> values; // id list that corresponds to the keys for the list above Set<Long> ids;
If any member...
Started by Ike Walker on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
What's a good way to do this in Java?
Replace LinkedHashMap<Long, BigInteger....
EDIT: options for sorting, then dumping it back into the list of object arrays .
Querying for a key that has no values returns an empty collection.
Library.
|
|
How do I replace using the following code?
ereg_replace("%Data_Index\[.\]%", $this->resultGData[$key ][\\1], $var)
I want to replace the number in [] %Data_Index
to $this->resultGData[$key ][\\1] same %Data_Index
and how ex %Data_Index[1] = $this...
Started by monkey_boys on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Hello monkey_boys
your question is a little bit hard to understand
the smartest way to replace what[$key ][] has 10 elements on them you could simply do this, asuming %Data_Index[1] (are you sure[$key ]); //we get the total of elements....
|