Changing string to array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thewormman
Forum Newbie
Posts: 11
Joined: Sat Aug 28, 2004 1:11 pm

Changing string to array

Post by thewormman »

Hi
Could someone tell me in laymans language how I can turn this string

Code: Select all

<?php
 $catid = array_shift(mysql_fetch_row(mysql_query("select id from lma_categories where parent = '$ipar' and name = '".str_replace("_", " ", $lastcat)."'")));   
?>
Into an array?
As when I execute the script it is in I get the following error message
Warning: array_shift() [function.array-shift]: The argument should be an array in /home3/davemcc/public_html/1coolwebsite.co.uk/lma/directory on line 774
Many thanks
Dave
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

break the line apart into individual function calls. Although it can be fun to compact code into the smallest space, it is counter productive when still learning and developing. You likely have an error in the sql or maybe the query found zero records.
Post Reply