How to implement a loop in php [closed] - php

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Hi I'm totally new here and with and would glad if someone could help as I'm stuck with how I can create a loop with some php code.
$TotalUniques = $this->TotalUniquesHits($Counts[$xx]['ID']);
The value I'm after is [$xx] which represents a position in the array. How to change it so that I get $TotalUniques looping through all the values of $xx?

You can try with foreach loop:
foreach($Counts as $xx){
$TotalUniques[] = $this->TotalUniquesHits($xx['ID']);
}
You may also consider checking if each $xx has ID key with isset or array_key_exists.

Related

How to concatenate two or three arrays together in php? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
For Example:
if the output is coming like this
array([0]=>1) array([0]=>2) array([0]=>3)
How to combine them like this:
array([0]=>1,[1]=>2,[2]=>3)
Thanku very much
Please Guys help me with this problem
Simple answer based on what you supply:
$new_array = array_merge($array1, $array2, $array3);

why the OpenServer displays the code in a string [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
why the OpenServer displays the code in a string but not in the column as indicated in the light image. I do everything the same, but I have everything on the line?
please help me, what am I doing wrong?
this is my code:
and this is my output and all one line:
but it should be like this[original of the required output]
You have var_dump($x) in there two times, which will display the array as a string like in your image. But the echo $x[0] is displayed/echoed correctly in between those two - as "18".
If you want to echo all values of the array, you need a foreach loop, like
foreach($array as $value) {
echo "<p>".$value."</p>";
}
EDIT AFTER COMMENT:
Put the arrays into pre tags and use print_r($x); instead of var_dump($x), like
<pre>print_r($x);</pre>

PHP Illegal array key type warning (PHPStorm) [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Here is my example code
It actually works on server but I wonder why do I get this warning?
Thanks
You can't use float number as array index.
To change floats to integer use function like intval

How to remove a key of an array? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I need to remove [picture_names] from my array. Help me to remove this?
Use unset function:
unset($array['picture_names']);
You can do it with unset() function. Documentation here.
$result = unset($yourArray['picture_names']);
var_dump($result);

Laravel function name must be a string [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
Laravel
What mistake am I actually doing?
Please have a look at the image below:
http://1drv.ms/1ybX4Cg
I think
$body['user_id'] = $user()->id;
should be
$body['user_id'] = $user->id;

Categories