Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
Break a string into an array:
<?php
$str = "Hello world. It's a beautiful day.";
print_r (explode(" ",$str));
?>
by გიორგი ბაკაშვილი
4 years ago
0
PHP
String
PHP official doc
1
Return the number of elements in an array:
<?php
$cars=array("Volvo","BMW","Toyota");
echo sizeof($cars);
?>
by გიორგი ბაკაშვილი
4 years ago
0
PHP
Array
PHP official doc
0
Remove duplicate values from an array:
<?php
$a=array("a"=>"red","b"=>"green","c"=>"red");
print_r(array_unique($a));
?>
by გიორგი ბაკაშვილი
4 years ago
0
PHP
Array
PHP official doc
0
Remove elements from an array and replace it with new elements:
<?php
$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$a2=array("a"=>"purple","b"=>"orange");
array_splice($a1,0,2,$a2);
print_r($a1);
?>
by გიორგი ბაკაშვილი
4 years ago
0
PHP
Array
PHP official doc
1
Start the slice from the third array element, and return the rest of the elements in the array:
<?php
$a=array("red","green","blue","yellow","brown");
print_r(array_slice($a,2));
?>
by გიორგი ბაკაშვილი
4 years ago
1
PHP
Array
PHP official doc
-1
Calculate and return the product of an array:
// Returns product of the array members
echo array_product([5,5]);
by გიორგი ბაკაშვილი
4 years ago
0
PHP
Array
PHP official doc
1
Assign variables as if they were an array:
<?php
$my_array = array("Dog","Cat","Horse");

list($a, $b, $c) = $my_array;
echo "I have several animals, a $a, a $b and a $c.";
?>
by გიორგი ბაკაშვილი
4 years ago
0
PHP
Array
PHP official doc
0
Merge two arrays into one array:
$a1=["red","green"];
$a2=["blue","yellow"];
print_r(array_merge($a1,$a2));
Merge two associative arrays into one array:
$a3=["a"=>"red","b"=>"green"];
$a4=["c"=>"blue","b"=>"yellow"];
print_r(array_merge($a3,$a4));
Using only one array parameter with integer keys:
$a=array(3=>"red",4=>"green");
print_r(array_merge($a));
by გიორგი ბაკაშვილი
4 years ago
1
PHP
Array
PHP official doc
0
Output the value of the current element in an array:
$people = ["Peter", "Joe", "Glenn", "Cleveland"];

echo current($people);
by გიორგი ბაკაშვილი
4 years ago
0
PHP
Array
PHP official doc
1
laravel compact()
return more than one array then use compact('array1', 'array2', 'array3', ...) to return view.
return view('viewblade', compact('view1','view2','view3','view4'));
On the other hand, you can use
with()
:
return View:('viewblade')
->with(compact('view1','view2','view3','view4'));
by გიორგი ბაკაშვილი
4 years ago
0
Laravel
1
Results: 1578