newbie at php , need help with ereg function and arrays

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
User avatar
massiveone
Forum Commoner
Posts: 29
Joined: Tue Jun 18, 2002 4:39 pm
Location: Canada
Contact:

newbie at php , need help with ereg function and arrays

Post by massiveone »

Im new to php so anyhelp would be greatly appreciated.
im pulling data from a sql database and the data consists of itemcodes
and qauntitys. my problem is that the item codes contain information about an item.
it 1001xl 1000m same item different size
how could i parse the output to look like
item m xl
1001 1 1

??
anyhelp would be greatly appreciated, thanks.
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

You could use this:

http://www.php.net/manual/en/function.parse-str.php

and concatenate the first four items in the array then echo the remaining items with the proper spacing.

Direwolf
User avatar
massiveone
Forum Commoner
Posts: 29
Joined: Tue Jun 18, 2002 4:39 pm
Location: Canada
Contact:

trouble coding

Post by massiveone »

thankyou for the helpful page.
im still having trouble coding it though as im new to this ;op
could you give me some example syntax
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

Look at this:

Code: Select all

<?
         $word="100110";
         $first_string=$word&#1111;'0'].$word&#1111;1].$word&#1111;2].$word&#1111;3]; 
         echo $first_string." ".$word&#1111;4]." ".$word&#1111;5]; 
?>
The value of the var $word is a string of which can be referd to as an array.

Direwolf[/quote]
Post Reply