Output $_GET from array [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Hello I had a link...
'process.php?wpn=somevaluehere'
Where I want whatever value place on 'wpn' must get another value from array of values example.
array (
"somevaluehere" => 5,
"somevalue10" => 10,
"somevalue20" => 20
);
then how I can output the array values, been trying to search over google but I failed to find it since I am very new PHP programmer but I learn pretty fast and somehow can understand them. And if it can't be found on the array list, I wish it do nothing.

$values = array(
"somevaluehere" => 5,
"somevalue10" => 10,
"somevalue20" => 20
);
echo $values[$_GET['wpn']];

Related

how to convert php number string into number array [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
I want to compare each digit of a number array. Like: 5450...i want to compare each of the digit such as: 5,4,5,0 individually with other number.for that i want to convert this number string in number array.how to do this?
you can use str_split to convert the string in to Array
For example:
<?php
$str="5450";
$arr=str_split($str);
print_r($arr);
?>
output:
Array ( [0] => 5 [1] => 4 [2] => 5 [3] => 0 )
You can use preg-split - see example two here: http://us3.php.net/manual/en/function.preg-split.php

How to create variables with the contents of matrix arrays? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
If I have an array with identifiers like this "name" => "Manoel", "age" => 45 then how can I turn them into individual variables without having to know each identifier in the array? is it possible?
Can I do that inside a class to create new properties?
Thanks.
Try this:
<?php
$Wales = 'Swansea \n';
print $Wales;
$capitalcities['England'] = 'London';
$capitalcities['Scotland'] = 'Edinburgh';
$capitalcities['Wales'] = 'Cardiff';
extract($capitalcities);
print $Wales;
?>
The result you should see in your browser is:
Swansea
Cardiff
And yes, if you do this inside an object you may have those variables as properties in execution time.

How to convert this array in another array? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have this array:
array(
(int) 1 => 'igor.cesar#soreq.com.br',
(int) 5 => 'igorpol#gmail.com',
(int) 6 => 'kkk#asasa.com'
)
I want to convert to this:
array('igor.cesar#soreq.com.br','igorpol#gmail.com','kkk#asasa.com')
How can I do this?
You could use the array_values function:
array_values($yourarray);
i would do it like this.
foreach($yourArray as $v)
{
$newArray[]=$v;
}
explanation
for each value of your array put it in a new array called $newArray

Can foreach loop contain value as an object? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
foreach ($result as $key => $value) {
}
In this can the $value be an object like the following given below ,
where 10 is the key and other is value
[10] => stdClass Object
(
[nid] => 80
[type] => create_an_account
)
Is this valid ??
I would love to make a long answer but I can't develop more than: Yes it is. For your culture, this is extract from the foreach doc:
The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable. There are two syntaxes:
Before asking on SO, you can try by yourself :)

How to pass more than one php arrays to python script using json [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am new to json and I am facing a problem in sending more than one 2D array to python script from php script for calculation. Can anyone help me with that?
Build an array-of-arrays and encode that?
$meta_arr = array(
'array1' => $array_number_one,
'array2' => $array_number_two
);
echo json_encode($meta_arr);

Categories