Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

i can't understand "key=>value" this code in php?

Tags:

php

I got a question about the "$key => $value" in the code below... I looked it up in google but it didn't returned any results.. All I know is that "=>" is used in arrays like x = array('a' => 'b').

function _stripslashes_rcurs($variable,$top = true)
    {
        $clean_data = array();
        foreach($variable as $key => $value)
        {
            $key = ($top) ? $key : stripslashes($key);
            $clean_data[$key] = (is_aray($value)) ?
                stripslashes_rcurs($value, false) : stripslashes($value);
        }
        return $clean_data;
    }

thank you for your help

like image 317
user126726 Avatar asked Jun 18 '26 17:06

user126726


1 Answers

Basically it's looping through $variable and setting the key as $key and the value as $value. So let's say this is your arrray:

$variable = array(
  'a' => 'A'
  'b' => 'B'
  'c' => 'C'
);

Then in each iteration of the loop, $key would be one of the lowercase letters, and $value would be the corresponding uppercase letter.

like image 98
Sasha Chedygov Avatar answered Jun 21 '26 06:06

Sasha Chedygov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!