$sampleArray = [ 'one' => true, 'two' => true, 'three' => true, ];
$sampleArray['one']; would be true
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I am very new to PHP programming and Laracast. I have an array and I want to select all its indexes with * or something. I want to save the same value to all its indexes. I am trying it in laravel.
For example: public funciton arrayFunction() { $sampleArray = [ 'one' => true, 'two' => true, 'three' => true, ]; return $sampleArray; }
public function one() { $sampleArray = $this->arrayFunction(); // code to sell array index value False except one }
public function two() { $sampleArray = $this->arrayFunction(); // code to sell array index value False except two }
how can I do it without using foreach loop. Is it possible? If yes, how can I do it?
This is my first post on Laracast. Sorry for my bad English and if anything goes wrong through this post.. Thanks in advance.
Please or to participate in this conversation.