Answers for "array insert php"

PHP
2

array_push php

<?php
$cesta = array("laranja", "morango");
array_push($cesta, "melancia", "batata");
print_r($cesta);
?>
Posted by: Guest on April-26-2020
5

php add item to array

<?php
  $z = ['me','you', 'he'];
  array_push($z, 'she', 'it');
  print_r($z);
?>
Posted by: Guest on June-02-2020
1

php insert in array

$original = array( 'a', 'b', 'c', 'd', 'e' );
$inserted = array( 'x' ); // not necessarily an array, see manual quote

array_splice( $original, 3, 0, $inserted ); // splice in at position 3
// $original is now a b c x d e
Posted by: Guest on June-04-2020
0

php insert array into mysql

if(is_array($records)){
 
    $DataArr = array();
    foreach($records as $row){
        $fieldVal1 = mysqli_real_escape_string($conn, $row[0]);
        $fieldVal2 = mysqli_real_escape_string($conn, $row[1]);
        $fieldVal3 = mysqli_real_escape_string($conn, $row[2]);
 
        $DataArr[] = "('$fieldVal1', '$fieldVal2', '$fieldVal3')";
    }
 
    $sql = "INSERT INTO programming_lang (field1, field2, field3) values ";
    $sql .= implode(',', $DataArr);
 
    mysqli_query($conn, $query);
}
Posted by: Guest on October-11-2021
0

php insert array into mysql

if(is_array($records)){
    foreach ($records as $row) {
        $fieldVal1 = mysqli_real_escape_string($conn, $row[0]);
        $fieldVal2 = mysqli_real_escape_string($conn, $row[1]);
        $fieldVal3 = mysqli_real_escape_string($conn, $row[2]);
 
        $query ="INSERT INTO programming_lang (field1, field2, field3) VALUES ( '". $fieldVal1."','".$fieldVal2."','".$fieldVal3."' )";
        mysqli_query($conn, $query);
    }
}
Posted by: Guest on October-11-2021

Browse Popular Code Answers by Language