09-30-2011
My mistake. You don't use single quotes inside double quotes for associative array keys, you leave the string unquoted.
PHP Code:
<?php $VAR_NAME=array("z" => "a", "q" => "b");
print "$VAR_NAME[q]\n"; ?>
EOF
b
---------- Post updated at 04:30 PM ---------- Previous update was at 04:27 PM ----------
You'd want to quote
everything you use from $campaign_row, by the way, not just the array key. The one you convert to (int) should be fine though.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Dear all,
We are planning on upgrading our current HP unix 64 bites from version 11.0 to 11.11. I would like to find out all the possible problems that we will encounter especially on the application side. Can anyone provide me with list(s) or link(s) where I can find out more information?
... (0 Replies)
Discussion started by: wujee
0 Replies
2. Shell Programming and Scripting
hi,
i have 3 fields in a file and linked them through 2 associative arrays.. the problem is one of the associative array is working while the other is not.. the code part is:
awk ' BEGIN {
FS="|"
rc = getline < "ICX_RULES"
while ( rc == 1 )
{
rule_id=$1
rule_parameter=$2... (2 Replies)
Discussion started by: aami_sayan
2 Replies
3. Shell Programming and Scripting
Hi,
I'm looking for help trying to parse a data stream. Any help would be greatly appreciated.
My awk statement is
awk '/Aug/{a=$2}/vol/{print a, host, $1, $2, $3, $4, $5}' out.txt
Sample Data Stream "out.txt"
-----------------------------
# Aug 3 00:00:00 2008
===== DF =====... (3 Replies)
Discussion started by: jmd2004
3 Replies
4. Shell Programming and Scripting
Hi.
I have a file with the following structer:
DB DISK LOCATION SIZE
============================================
PROD DATA_01 /dev/dm-23 10
PROD DATA_02 /dev/dm-24 10
PROD DATA_03 /dev/dm-25 10
DEV DATA_04 /dev/dm-26 10
DEV DATA_05 ... (1 Reply)
Discussion started by: yoavbe
1 Replies
5. Shell Programming and Scripting
PHP question...I posted this on the Web Development forum, but maybe this is a better place!
I have an SQL query that's pulled back user IDs as a set of columns. Rather than IDs, I want to use their names.
So I have an array of columns $col with values 1,7,3,12 etc and I've got an array $person... (3 Replies)
Discussion started by: JerryHone
3 Replies
6. Web Development
PHP question...
I have an SQL query that's pulled back user IDs as a set of columns. Rather than IDs, I want to use their names.
So I have an array of columns $col with values 1,7,3,12 etc and I've got an array $person with values "Fred", "Bert", "Tom" etc
So what I want to do is display the... (3 Replies)
Discussion started by: JerryHone
3 Replies
7. Shell Programming and Scripting
Guys,
I need to iterate populate an array while going over files in directory. Can someone please tell me syntax I tried this but it isn't working ==>
for F in `ls -p "${directory1}" | grep -v "\/"`
do
cd "${directory2}"
cmp "${directory2}"/"${F}" "${directory1}"/"${F}" ... (2 Replies)
Discussion started by: Veenak15
2 Replies
8. Shell Programming and Scripting
Hi,
I need an elegant solotion in php. I need to compare 2 arrays (array1 & array2), to find all instances of array 2 which is not in array1.
I don't want to see any instances of array1 wich is not in array2 (here "the")
Array1: This, is, the, data, of, array1
Array2: this, is, data, Of,... (2 Replies)
Discussion started by: lowmaster
2 Replies
9. Programming
Hi,
I have to create a JList and the items I need to display are store in HashMap table. What would be the easiest way to populate this JList. Basically the items I want to display/show in the JList are the key values of the HashMap. Thanks in advance for any suggestions. (0 Replies)
Discussion started by: arizah
0 Replies
10. Programming
if i declare both but don't input any variables what values will the int array and file pointer array have on default, and if i want to reset any of the elements of both arrays to default, should i just set it to 0 or NULL or what? (1 Reply)
Discussion started by: omega666
1 Replies
LEARN ABOUT PHP
stripslashes
STRIPSLASHES(3) 1 STRIPSLASHES(3)
stripslashes - Un-quotes a quoted string
SYNOPSIS
string stripslashes (string $str)
DESCRIPTION
Un-quotes a quoted string.
Note
If magic_quotes_sybase is on, no backslashes are stripped off but two apostrophes are replaced by one instead.
An example use of stripslashes(3) is when the PHP directive magic_quotes_gpc is on (it was on by default before PHP 5.4), and you aren't
inserting this data into a place (such as a database) that requires escaping. For example, if you're simply outputting data straight from
an HTML form.
PARAMETERS
o $str
- The input string.
RETURN VALUES
Returns a string with backslashes stripped off. ( ' becomes ' and so on.) Double backslashes ( \) are made into a single backslash ( ).
EXAMPLES
Example #1
A stripslashes(3) example
<?php
$str = "Is your name O'reilly?";
// Outputs: Is your name O'reilly?
echo stripslashes($str);
?>
Note
stripslashes(3) is not recursive. If you want to apply this function to a multi-dimensional array, you need to use a recursive func-
tion.
Example #2
Using stripslashes(3) on an array
<?php
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
// Example
$array = array("f\'oo", "b\'ar", array("fo\'o", "b\'ar"));
$array = stripslashes_deep($array);
// Output
print_r($array);
?>
The above example will output:
Array
(
[0] => f'oo
[1] => b'ar
[2] => Array
(
[0] => fo'o
[1] => b'ar
)
)
SEE ALSO
addslashes(3), get_magic_quotes_gpc(3).
PHP Documentation Group STRIPSLASHES(3)