Novice question
| From: | brendan conroy | Date: | Fri, 15 Feb 2002 21:03:18 +0000 |
| Subject: | Novice question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-84977@lists.php.net to get a copy of this message | ||
Hi,thanks for reading this!
This problem has got me beat! I cant figure out how to insert a minus sign into each element in an array of strings.
I keep getting the error that the first element in array_push has to be an array, no matter what method I've tried, and I cant think of any more!
Im trying to isolate terms in polynommials, which Ive stored in an array m[] like this:
$m[0]="-3x_1^6/7-4x_2^3/5";
$m[1]="-4x_3^2/3-7x_4/7";
/*Each element in m has two terms, and I want to isolate these by exploding on the minus sign, thus giving me four elements, which then need to have a minus inserted into them.
I take one of the four elements in $ss, and for each character I push it into a temporary storage array $test, then I reverse $test so the term is in the correct order, and then I insert the minus sign at the start. But funnily enough, there seems to be a flaw in my logic or code. What Ive written so far is*/
$ss=explode("-",$m);
for($cnt=1;$cnt<count($ss);$cnt++)
{
for($waa=0;$waa<$cnt;$c++)
{
array_push($test,$ss[$waa])
}
array_reverse($test);
array_push($test,"-");
array_push($real,$test);
I would be extremely grateful for anyones assistance, thanks a million,
Regards
Bren
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com