How do I add a static value as first element or starting of my array? The data for array is coming from my database.
Below I am trying to add “Select Style” in the front but not it is just combing my first to elements.
$query = "SELECT DISTINCT name FROM ImageInfo";
$db = new connection();
$result = $db->query($query);
while($info = mysql_fetch_array($result)){
$content[] = $info;
}
$result=array();
$count = count($content);
$result[0][] = "Select Style";
for ($x=0;$x<$count;++$x)
{
$result[$x][] = $content[$x]['name'];
}
echo json_encode($result);
@Denoteone, Following should do the trick,