Hi @oxy
I am using this code which brings back a list of keys in $frameIDs_hash i am trying to get the values of these keys to build an array can i do this on the fly like add key value to array in php
foreach my $frame (keys %$frameIDs_hash) {
$request = new HttpRequestMessage($this->url, $frame);
}
Thans Denise
Hello! I think this should be asked on Stack Overflow, but not here. Anyways, here’s the answer generated by the AI.
Yes, you can create an array and add key-value pairs to it on the fly using PHP. Here’s an example based on your code snippet:
phpCopy code
// create an empty array to hold the key-value pairs
$data = array();
foreach my $frame (keys %$frameIDs_hash) {
// create a new HttpRequestMessage with the current key as the value
$request = new HttpRequestMessage($this->url, $frame);
// add the key-value pair to the $data array
$data[$frame] = $request->send(); // or whatever value you want to add
}
// now $data will contain all the key-value pairs from $frameIDs_hash
In this example, $data[$frame]
is used to add the key-value pair to the array, where $frame
is the current key from the foreach
loop, and $request->send()
is the value to be added. You can replace this with any value you want to add to the array.
1 Like
@TheGreatTemplier How about if i wanted two entries for one key sorry to be so vague and thank you for the answer and looking
I am trying to get keys and values
snippit
private function request_all_tag_ID3v2_3() {
$request = new HttpRequestMessage($this->url, 'truename');
$this->frameIDs_hash = $http_streaming->request_all_tags();
foreach my $frame (keys %$frameIDs_hash) {
$request = new HttpRequestMessage($this->url, $frame);
}
return $request->content();
}
Don’t worry i dont think i am going to bother with this anymore its a complete waste of time trying to get anything to work . but thanks for looking bye