I run a query and got id values in an array. Then I push those id like this array_push($id); then I implode ',' into an array and place it in a variable like this $val = implode(",",$id);. When I output it i get following result
,2,3,4,5,6,7,8. Problem in this result is that first value is ',' and it is because first record that I am getting from database is giving me Null value. I want to remove ',' from first place if first record is empty. So that desire result should be 2,3,4,5,6,7,8.
Please anybody can help me how can I remove ',' from first place. Or any suggestion to solve this problem
WHERE id IS NOT NULLin your SQL query.array_filteras Baba mentions (btw, you must provide a custom callback to distinguishnullfrom0). But is making them go away the correct thing to do? That depends on your business rules.