JREAM Posted February 20, 2009 Share Posted February 20, 2009 How would I go about doing this? Because the items in the createItem list (below) only appear as $item. createItem($sqlcol, 'title, slug, breadcrumb, keywords, description, content, parent_id, position'); How would I make colNames have them broken down like that? function createItem($sqlcol, $items) { $colNames = array($items); print_r($items); // .. etc .. Link to comment https://forums.phpfreaks.com/topic/146085-solved-array-inside-function-probably-an-easy-one/ Share on other sites More sharing options...
JREAM Posted February 20, 2009 Author Share Posted February 20, 2009 trying to do explode $colNames = explode($items, ','); Link to comment https://forums.phpfreaks.com/topic/146085-solved-array-inside-function-probably-an-easy-one/#findComment-766898 Share on other sites More sharing options...
JREAM Posted February 20, 2009 Author Share Posted February 20, 2009 Okay I had it backwards $colNames = explode(',',$items); Link to comment https://forums.phpfreaks.com/topic/146085-solved-array-inside-function-probably-an-easy-one/#findComment-766900 Share on other sites More sharing options...
ILMV Posted February 20, 2009 Share Posted February 20, 2009 Use this... $colNames=split(',',$items); Link to comment https://forums.phpfreaks.com/topic/146085-solved-array-inside-function-probably-an-easy-one/#findComment-766901 Share on other sites More sharing options...
genericnumber1 Posted February 20, 2009 Share Posted February 20, 2009 <?php $colNames = explode(', ', $items); ?> Or better yet... <?php createItem($sqlcol, array('title', 'slug', 'breadcrumb', 'keywords', 'description', 'content', 'parent_id', 'position')); <?php function createItem($sqlcol, $items) { print_r($items); } But as far as proper programming style, it would likely be best to cut down on the amount of those parameters. It seems like the function is probably too general and could stand to be split into more specialized functions. Link to comment https://forums.phpfreaks.com/topic/146085-solved-array-inside-function-probably-an-easy-one/#findComment-766902 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.