Jump to content

[SOLVED] Array inside Function, Probably an Easy one


JREAM

Recommended Posts

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 ..

<?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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.