In my form im outputting some json or a string of data that is an array from Input::old('tags') the problem I'm having is being able to test it and see if it is json and if it is do a foreach loop and put the tag attribute is an array then implode the array and output it in an input field.
[{"id":112,"tag":"corrupti","tagFriendly":"corrupti","created_at":"2015-07-20 00:05:28","updated_at":"2015-07-20 00:05:28","pivot":{"question_id":60,"tag_id":112,"created_at":"2015-07-20 00:05:28","updated_at":"2015-07-20 00:05:28"}},{"id":9,"tag":"placeat","tagFriendly":"placeat","created_at":"2015-07-20 00:05:23","updated_at":"2015-07-20 00:05:23","pivot":{"question_id":60,"tag_id":9,"created_at":"2015-07-20 00:05:28","updated_at":"2015-07-20 00:05:28"}}]
So my output should look like this
'corrupti, placeat, etc...'
Could someone help me get the desired result following the steps I just outlined
This code doesn't work but it's what I kinda need to happen. is_array is always false
<?php
$tags = Input::old('tags');
if(is_array($tags)) {
foreach ($tags as $tag) {
$tags[] = $tag->tag;
}
$tags = implode(', ', $tags);
}
?>