Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Example,
$params = array($demandnum,$demandnum,$demandnum,$demandnum,$demandnum,$demandnum,$demandnum,$demandnum,$demandnum,$demandnum,$demandnum,$demandnum );
$stmt = $this->db_gcm->query($query, $params);
$test = $stmt->row();
print_r($test);
Result,
stdClass Object( [server_price] => 32398.63 [server_unit] => 2 [network_price] => 0.00
[network_unit] => 3 [storage_price] => 4948.02 [storage_unit] => 2
[loadbalancer_price] => 2200.00 [loadbalancer_unit] => 1
[additionalservice_price] => 105375.60 [additionalservice_unit] => 4 [support_price] => [support_unit] => 0)
I want to add key value in here.
Is there any good idea?
I want to add key value in here.
In where? $test? How about
$test->key = 'value';
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
i have a this string 1=>aaabba;4=>bsbsbsb;7=>flkdsl;5=>jdsfkjhsfd;
I want to change it in an array with such form:
[1] => aaabba
[4] => sbsbsb
[7] => flkdsl
[5] => jdsfkjhsfd
how to do it?
Language PHP.
use explode
$result_array = array();
$str = "1=>aaabba;4=>bsbsbsb;7=>flkdsl;5=>jdsfkjhsfd;";
$temp_array = explode(";",$str);
$temp_array = array_filter($temp_array);
foreach($temp_array as $val)
{
$sub_temp_array = explode("=>",$val);
$result_array[$sub_temp_array[0]] = $sub_temp_array[1];
}
print_r($result_array);
DEMO
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have this array:
Array ( [e] =>
[r] =>
[c] =>
[Overflow] =>
[f] =>
[b] => [
true] =>
[Stck] =>
[d] =>
[js] =>
)
and i need to get this
e, r, c, Overflow, f, b, true, stck, d, js
The data you want is in the keys of your array, not the values. So you have to implode the keys:
implode(', ', array_keys($array));
use implode() implode — Join array elements with a string
Implode
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have this array:
[12] => Array
(
[groupID] => 19
[groupApprovalRefID] => 123433322
[jobrequisitionRefID] => eRS/2015/00023/021/HQ
[groupApprovalSubject] => Principle
[jobrequisitionGroupID] => 19
[groupCreatedDate] => 2015-05-13 14:43:55
[groupReference] => HQ/05/2015/016/00016
)
But I need Group ID like this:
[19]=> Array
(
[groupApprovalSubject] => Principle
[jobrequisitionGroupID] => 19
[groupCreatedDate] => 2015-05-13 14:43:55
[groupReference] => HQ/05/2015/016/00016
)
You can loop over each element of your array and create a new array with the indexes you want.
$result_array = array();
foreach ($original_array as $value)
{
$result_array[$value['groupID']] = $value;
}
Note that if groupIP isn't unique, some values may be lost, since PHP arrays have unique indexes.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Here is an example:
PHP:::
<?php
$tag = id3_get_tag( "path/to/example.mp3" );
print_r($tag);
?>
response
Array
(
[title] => DN-38416
[artist] => Re:\Legion
[album] => Reflections
[year] => 2004
[genre] => 19
)
I want to set this like
$title => DN-38416
$artist => Re:\Legion
$album => Reflections
If you mean to assign value to new variables, simply do it using the assignment operator = in PHP.
$title = $tag["title"];
$artist = $tag["artist"];
// ... and so on
Read more about assignment operator in PHP.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have an array labeled $friendRequest.
When i do echo print_r($friendRequest), I get
Array (
[result] => Array (
[0] => Array (
[id] => 11
)
)
)
The part that I care about is [id]=>11, I want to assign that value to a variable. So lets say i have variable $a, $a = 11 is what i want. How can I do this?
Do this:
$a = $friendRequest['result'][0]['id']
var_dump($a); //int 11
you can do that with a code like this:
$a = array['id'];
I guess your array is called "$friendrequest" so let's say
$a = $friendRequest['result'][0]['id']
echo $a;