0

I have a PHP array

$logEnabled = explode(',',$baby->logEnabled);
// dd($logEnabled);

result

array:3 [▼
  0 => "pee"
  1 => " poop"
  2 => " feed"
]

I'm trying to pass that to JS , I did this

console.log({{json_encode($logEnabled) }});

I kept getting

["pee"," poop"," feed"]

I want to see [pee,poop,feed]

Any hints for me

0

2 Answers 2

-1

You can try

$logEnabled = "[".$baby.logEnabled."]"

Now, $logEnabled contains the JS array.

Sign up to request clarification or add additional context in comments.

1 Comment

I do that in JS or in PHP ?
-1

Try this I'm sure this will work

var app = @json($logEnabled);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.