Page 1 of 1

newbie at php , need help with ereg function and arrays

Posted: Tue Jul 09, 2002 9:12 am
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.

Posted: Tue Jul 09, 2002 9:27 am
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

trouble coding

Posted: Tue Jul 09, 2002 10:20 am
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

Posted: Tue Jul 09, 2002 11:52 am
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]