1use Illuminate\Support\Arr; 2 3$array = ['p-4', 'font-bold' => $isActive, 'bg-red' => $hasError]; 4 5$isActive = false; 6$hasError = true; 7 8$classes = Arr::toCssClasses($array); 9 10/*11 * 'p-4 bg-red'12 */
Tip given by @dietsedev
1use Illuminate\Support\Arr; 2 3$array = ['p-4', 'font-bold' => $isActive, 'bg-red' => $hasError]; 4 5$isActive = false; 6$hasError = true; 7 8$classes = Arr::toCssClasses($array); 9 10/*11 * 'p-4 bg-red'12 */
Tip given by @dietsedev