Closed lablnet closed 5 years ago
Hi, is this open for anyone to help sort? I would like to try and get it to render nicely.
If so, would it be possible to have some more info on how you would like it to result?
Hi, is this open for anyone to help sort? I would like to try and get it to render nicely.
If so, would it be possible to have some more info on how you would like it to result?
Yes it is for everyone
Basically the dot
method convert arrays with dot notations like
here is dataset
$data = ['users' => ['name' => 'Umer']];
//when it converted to dot notation it can be access like
//users.name // Umer will be output
What is that am looking so far there should be flag
parameter which allow us to stop that conversion with specific key, consider above issue dataSet, i can provide key, types, or type, so it should return arrays, and stop converting...
What is that am looking so far there should be flag parameter which allow us to stop that conversion with specific key, consider above issue dataSet, i can provide key, types, or type, so it should return arrays, and stop converting...
Alright, thank you.
So for example, you example $dataSets
above, you would want an output of e.g.:
array(32) {
'files.mine.type.0' =>
string(28) "application/x-zip-compressed"
'files.mine.type.1' =>
string(18) "application/msword"
'files.mine.type.2' =>
string(71) "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
'files.mine.type.3' =>
string(9) "image/gif"
'files.mine.type.4' =>
string(10) "image/jpeg"
'files.mine.type.5' =>
string(10) "image/jpeg"
'files.mine.type.6' =>
....
string(3) "gif"
'files.types.image.4' =>
string(3) "ico"
'files.types.image.5' =>
string(3) "svg"
'files.types.zip.0' =>
string(3) "zip"
'files.types.zip.1' =>
string(3) "tar"
'files.types.zip.2' =>
....
string(4) "docx"
'files.types.media.0' =>
string(3) "mp4"
'files.types.media.1' =>
string(3) "mp3"
'files.types.media.2' =>
string(3) "wav"
'files.types.media.3' =>
string(3) "3gp"
}
Is that correct in the way of the output? ^^^^ That is the output of the modified code already at the moment.
Or when you say a that it should stop converting arrays, is that to stop when the conversion hits an associative array structure?
Actually, I think I just clicked as to what you saying having a look at the example data again.
So the conversion can happen with all the assoc. keys until the last thing it hits is not an array and then just stores the array as a complete element without the index number?
What is that am looking so far there should be flag parameter which allow us to stop that conversion with specific key, consider above issue dataSet, i can provide key, types, or type, so it should return arrays, and stop converting...
Alright, thank you.
So for example, you example
$dataSets
above, you would want an output of e.g.:array(32) { 'files.mine.type.0' => string(28) "application/x-zip-compressed" 'files.mine.type.1' => string(18) "application/msword" 'files.mine.type.2' => string(71) "application/vnd.openxmlformats-officedocument.wordprocessingml.document" 'files.mine.type.3' => string(9) "image/gif" 'files.mine.type.4' => string(10) "image/jpeg" 'files.mine.type.5' => string(10) "image/jpeg" 'files.mine.type.6' => .... string(3) "gif" 'files.types.image.4' => string(3) "ico" 'files.types.image.5' => string(3) "svg" 'files.types.zip.0' => string(3) "zip" 'files.types.zip.1' => string(3) "tar" 'files.types.zip.2' => .... string(4) "docx" 'files.types.media.0' => string(3) "mp4" 'files.types.media.1' => string(3) "mp3" 'files.types.media.2' => string(3) "wav" 'files.types.media.3' => string(3) "3gp" }
Is that correct in the way of the output? ^^^^ That is the output of the modified code already at the moment.
Or when you say a that it should stop converting arrays, is that to stop when the conversion hits an associative array structure?
The out put should be
files.mine.type
after that there should be assos array
yes it should stop, but when $fllag
key argument
its look slightly complicated to me
Actually, I think I just clicked as to what you saying having a look at the example data again.
So the conversion can happen with all the assoc. keys until the last thing it hits is not an array and then just stores the array as a complete element without the index number?
Yes it happed with all keys, but there should be way as i describe above
@Lablnet, awesome thank you
@Lablnet, I have the code outputting the following when a flag is set:
[
"files.mine.type" => [
"application/x-zip-compressed",
"application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"image/gif",
"image/jpeg",
"image/jpeg",
"audio/mpeg",
"video/mp4",
"application/pdf",
"image/png",
"application/zip",
"application/et-stream",
"image/x-icon",
"image/icon",
"image/svg+xml",
],
"files.types.image" => [
"jpg",
"png",
"jpeg",
"gif",
"ico",
"svg",
],
"files.types.zip" => [
"zip",
"tar",
"7zip",
"rar",
],
"files.types.docs" => [
"pdf",
"docs",
"docx",
],
"files.types.media" => [
"mp4",
"mp3",
"wav",
"3gp",
],
]
Is that end result okay?
The syntax to access that would be:
$array = new Arrays;
var_export($array->dot($dataSets, true));
If not set it will default to the old method.
@Lablnet, I have the code outputting the following when a flag is set:
[ "files.mine.type" => [ "application/x-zip-compressed", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "image/gif", "image/jpeg", "image/jpeg", "audio/mpeg", "video/mp4", "application/pdf", "image/png", "application/zip", "application/et-stream", "image/x-icon", "image/icon", "image/svg+xml", ], "files.types.image" => [ "jpg", "png", "jpeg", "gif", "ico", "svg", ], "files.types.zip" => [ "zip", "tar", "7zip", "rar", ], "files.types.docs" => [ "pdf", "docs", "docx", ], "files.types.media" => [ "mp4", "mp3", "wav", "3gp", ], ]
Is that end result okay?
The syntax to access that would be:
$array = new Arrays; var_export($array->dot($dataSets, true));
If not set it will default to the old method.
Yeah that's exactly what I want
You're welcome to open PR
But you should consider the base method to implement this because you already seen the dot isn't base method right it just call another method
Thanks you so much for your time.
Looking forward to your PR.
Awesome, I did see that the dot()
method is just a wrapper 👍 .
I will finish it up and make a PR.
Let consider the following
DataSet
then consider following statement
It produce something like that result
Which is wrong, it should produce something like that
'files.mine.type. => array.'
There should be flag if we want to return array from specific key.
@peter279k what do you think?
https://github.com/zestframework/Zest_Framework/blob/master/src/Data/Arrays.php#L269