Reputation: 163
i used kirki drag and drop wordpress plugin for my site to create a sortable list when dragable is enabled.
i was able to create a setting that outputs this array, when i did var_dump for the settings here was what i got
array(3) { [0]=> string(10) "Big Grid 1" [1]=> string(10) "Big Grid 2" [2]=> string(10) "Big Grid 3" }
when in var_dump it sorts correctly when i drag and drop any element, they take there place as sorted in the var_dump array, to me the array given is completely useless till i set values for them .
so the question is how do i output them in php to get sorted just as they where in the array.
i tried switch case but its not working.
here is my code
foreach ($array[0] as $key => $value) {
switch ($key) {
case 'Big grid 1' :
// do something
break ;
case 'Big grid 2' :
// do something
break ;
case 'Big grid 3' :
// do something
break ;
}
}
please i need help on this one.
hope my question was clear.
i am no PHP expert, thus a complex answer would be well appreciated.
Upvotes: 0
Views: 67
Reputation: 5311
not sure what you are trying to do with using switch
statement and I'm not really sure what you are trying to accomplish with that code you have,
but as I understand about your question, you just want to output the value of an array,
then you can do something like
$items = array("Big Grid 1","Big Grid 2","Big Grid 3");
$output = '';
foreach ($items as $item ) {
$output .= $item .'<br/>';
}
echo $output; // or return $output if you need a return value
Upvotes: 2