GithubHelp home page GithubHelp logo

Bug in \Arrays class about framework HOT 10 CLOSED

lablnet avatar lablnet commented on June 6, 2024
Bug in \Arrays class

from framework.

Comments (10)

ReeceM avatar ReeceM commented on June 6, 2024 3

@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.

from framework.

ReeceM avatar ReeceM commented on June 6, 2024 1

@lablnet, awesome thank you

from framework.

ReeceM avatar ReeceM commented on June 6, 2024 1

Awesome, I did see that the dot() method is just a wrapper 👍 .

I will finish it up and make a PR.

from framework.

ReeceM avatar ReeceM commented on June 6, 2024

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?

from framework.

lablnet avatar lablnet commented on June 6, 2024

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...

from framework.

ReeceM avatar ReeceM commented on June 6, 2024

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?

from framework.

ReeceM avatar ReeceM commented on June 6, 2024

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?

from framework.

lablnet avatar lablnet commented on June 6, 2024

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

from framework.

lablnet avatar lablnet commented on June 6, 2024

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

from framework.

lablnet avatar lablnet commented on June 6, 2024

@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.

from framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.