webdevask.com

Menu

  • Home
  • New
  • Add question

Is there a php way to replicate a value multiple time in array, better than cycle?

View Original

one text

Solution:

Use

Fill an array with values

$var = 1;
$arr = array_fill(0, 3, $var);

The above code will create an array with $var from index 0 to the 3'th index

Try it online!

Source

See also:

  • php สร้าง Google ชีตจากบัญชีบริการ

  • php - Laravel 8.0 Installation Failed

  • javascript - How to include HTML data (tags) as value in "arrayToDataTable" of Google Pie Chart?

  • how to Grouping array in php

  • php - vender folder from my laravel project has more 1k error

© 2021
E-mail: contact@webdevask.com
Back to top