php - Insert specific value on first $key in array ← (PHP)

Solution:

Use

if(!empty($_POST['does_what']) && is_array($_POST['does_what'])){
    $strings = array();
    foreach($_POST['does_what'] as $key => $value){
        if($value[$key] == 0){
            $text = "This is ".$value
            $value = array_unshift($strings[$key], $text );
        }
        else{
            echo "Value is not a Zero";
        }
        $strings[] = $value;
    }
}
else{
    echo "Post is empty Or its not an array";
}

Answer



Solution:

I think you want something more like this:

foreach($_POST as $key => $value){
    if (count( $strings) == 0)
        $strings[] = "This is $value";
    else
        $strings[] = $value;

Source