I’m trying to figure out the cleanest way to loop through the first item in an array twice. My foreach looks like this:
foreach ($array as $arr) {
$arr['item'];
}
The reason I’m asking is because I’m looping through and running a curl script that requires setting a cookie. On the first loop, it’s not setting properly but it is on all others. Ideally I’d like to just hit that first twice, and overwrite the value I’m pulling.
If you need to make something twice with 1st element, you can make it this way
But instead of making it twice, maybe you should find out why it doesn’t work first time?
+1 to previous comment that you should fix a problem, but not workaround it.