implode

Error imploding $_POST[] array containing php variable

Hello, I am trying to implode an array in a $_POST[]. I am doing this inside of a loop which searches for values in ~31 arrays...$_POST['1'], $_POST['2'], $_POST['3'], etc. I am trying to do this with: while($i <= $_SESSION['daysInMonth']){ $month = $_SESSION['month']; $day = $i; $names = implode(',',$_POST['names_'.$i]); $region = $...

Storing associative array in MySQL DB

Hello, I'd like to store associative array containg mostly strings and integers as values in db. I was thinking: implode/explode - need to find delimiter, which won't be in values - since it's almost user generated, not safe XML - feels to heavy for the job (creating/reading values) json - if i need only to work with json_decode/json...

How to implode 2 dimensional array into square brackets

Hi guys, I would like to output my php array into this format: [1991, 6.5], [1992, 4], [1993, 5.9] PHP array: while ($row = mysqli_fetch_array($result)) { $metals[] = array('year' => $row['year'], 'metal' => $row['metal']; } I have seen some examples of implode function but I couldn't find any that could matc...

extract first 3 items in an array

$array = array('item1', 'item2', 'item3', 'item4', 'item5'); here i want to extract only the first three items in the array, and then $implodes = implode(';', $array); echo $implodes; which should output item1;item2;item3 $i=0; $new = array(); foreach($array as $arr) { $i++; if($i <= 3) { $new[] = $arr; } } doesn't ...

Removing any (first, middle, last, single) item in a CSV list via PHP's explode / implode

$pieces = explode(",", $userList); $key=array_search($deleteuser, $pieces); if(FALSE !== $key) { unset($pieces[$key]); } else return FALSE; $userList = implode(",", $pieces); I'm looking for inputs into how to rework this code to remove an element from a CSV list. The user should exist in this system and it should work fine e...

How to implode foreach

How to implode foreach() with comma? foreach($names as $name) { //do something echo '<a href="' . $url . '" title="' . $title . '">' . $name .'</a>'; } Want to add comma after each link, except the last one. ...

How to echo out all elements of php array at once ?

hi friends I have a php array for eg. $mob_numbers= array(12345674, 12345675, 12345676,12345677); I want to eacho out all of them at once so that it appears 12345674,12345675,12345676,12345677 (with comma) . How do i do it ? I tried array explode, didn't work. Pls help ...