How to convert this array in another 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
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

Related

Return array from table [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 field in my table with data: DE;RO;US;
Question is how extract data in array as:
$array = array('DE', 'RO', 'US');
use explode function.
Like this :
$string = 'DE;RO;US;';
$arr = explode(';',$string);
You can use the function explode() here.
$array = explode(';', $data);
The variable data is the result of you database query.
http://us1.php.net/manual/en/function.explode.php
BTW: Your way to save things in the database is not good. Have a look at database normalization.

Output $_GET from 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
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']];

Sum up array values [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
This is the array: http://www.stylechica.de/array.rtf (I can't copy it here)
I need to sum up ["PriceInformation"]["PriceInformation"]["PriceDetails"]["Price"] and allready tryed all kind of stuff like
foreach ($output["PriceInformation"]["PriceDetails"]["Price"] as $product)
echo array_sum($product);
but it just won't work. Any ideas?
Because $product refers to each iteration of $output["PriceInformation"]["PriceDetails"]["Price"], you can't sum the entire array like this. The best way to do it would be to add it to a variable as you go:
$your_sum = 0;
foreach($output as $value) {
$your_sum += $value['PriceInformation']['PriceDetails']['Price'];
}
echo 'Sum: ' . $your_sum;

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.

check array element in PHP [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
Could PHP check if a certain element in the array contains some words?
for example :
`[order_product_code] => I9300_cash397096569`
want to check if the element contains cash word.
If $array is your array of element:
foreach($array as $key=>$element) {
if(strpos('cash',$element) !== FALSE) echo "$key: ok";
else echo "$key: ko";
}

Categories