No, But you can use keys to get them.
Flatten keys?
Is it possible to get keys from flatten() helper
@MohamedTammam no, I havle multiD array, and I need keys and values...
@Ajvanho Can you please show an example.
@MohamedTammam It looks like this, I had to change the data due to the reason of the protection, but structure is this...
Illuminate\Support\Collection {#2573
#items: array:9 [
0 => array:3 [
"lhfdfhhf" => "hfddf"
"hfddf" => "XIUkKlzEufCabjfh"
"hfdhhfdf" => array:1 [
"content" => """
<p>By converting the collection to a LazyCollection, we avoid having to allocate a ton of additional memory. Though the original collection still keeps its values in memory, the subsequent filters will not. Therefore, virtually no additional memory will be allocated when filtering the collection's results..</p>
"""
]
]
1 => array:3 [
"hfdhf" => "tfdhcfjcfgn"
"hfdhdf" => "t1xJlgzJZkCPweBi"
"hffdhfd" => array:2 [
"tafdhfde" => ""
"fhdhdhf" => array:1 [
0 => array:3 [
"lhfdhdf" => "hfdhdh"
"kdhf" => "Q4o8MWBjywy9H4R5"
"hfdhfdhf" => array:1 [
"hfc" => array:6 [
0 => "438"
1 => "439"
2 => "440"
3 => "443"
4 => "444"
5 => "447"
]
]
@Ajvanho Okay, that's the data, how should it be after transforming?
@MohamedTammam For example, the key ‘hfdhfdhf’ appears in several places, but not in a clear sequence. I need all those key value pairs with that key.
collect($array)->flatMap(fn ($val) => $val)->all();
@tykus tnx, but this has no results
@Ajvanho ah... let me get my crystal ball then 🔮
@Ajvanho try an array flatten routine, example:
public function array_flatten($a, $flat = []) {
$entry = [];
foreach ($a as $key => $el) {
if (is_array($el)) {
$flat = $this->array_flatten($el, $flat);
} else {
$entry[$key] = $el;
}
}
if (!empty($entry)) {
$flat[] = $entry;
}
return $flat;
}
it would help you if you actually considered what you asked for
For example, the key ‘hfdhfdhf’ appears in several places
no it doesn't. You are not confused with hfdhf, or hfdhdf or fhdhdhf are you?
Please or to participate in this conversation.