Storing contents of a PHP array in a MySQL database

前端 未结 3 1831
清酒与你
清酒与你 2021-01-24 03:24

I am having trouble storing array contents in mysql I am using the code below

foreach($found_entry as $key => $sd) {
         echo \"$key => $sd 
3条回答
  •  日久生厌
    2021-01-24 03:45

    If I use $sd[0], only the first character is getting displayed.

    $sd is the value (e.g. "ST10928") of your array, but you're treating the value as an array itself, so $sd[0] must return only the first element (= letter).

    If you're trying to insert values from your array into the database (instead of iterating through the array and slicing the values), maybe you should use $found_entry[0] instead of $sd[0] and $found_entry[11] for $sd[11] ??

提交回复
热议问题