Probably very easy to do, but for some reason...
- From: "Paul F. Johnson" <paul@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 29 Jul 2008 18:16:44 +0100
Hi,
For some reason, my brain has gone to mush on a couple of things. Any help would be appreciated.
I have an array and a field passed into a function (call it $v) which is a string composed of comma sep values.
foo = array("one"=>1, "two", "three", "four", "five");
$ex = explode("," $v);
$newtext = "";
foreach ($ex as $e)
{
if ($e != "0")
$newtext .= " : " . $foo[$e];
}
The problem is that $e here is not being interpreted how I'd expect (I'd assume it to be a number). Do I need to cast $e as an int or is there something I'm missing?
A related problem comes from an sql query.
mysql_fetch_rows returns an array (bar). I pass this to another function. Next I try to iterate through.
The array appears to be a 2D array.
for ($m = 0; $m < count($bar); $m++)
{
for ($i = 0; $i < sizeof($bar[0]); $i++)
{
echo $bar['0']['3']; // works fine
echo $bar['0'][$i]; // doesn't work - same reason as above I'd imagine
}
}
Probably a really simple answer, but one I can't figure out. Help!!!!
TTFN
Paul
--
Sie können mich aufreizen und wirklich heiß machen!
** Posted from http://www.teranews.com **
.
- Follow-Ups:
- Re: Probably very easy to do, but for some reason...
- From: arkascha
- Re: Probably very easy to do, but for some reason...
- Prev by Date: Re: All possibilities from datasets? How to?
- Next by Date: phpmyadmin configuration
- Previous by thread: @some_function
- Next by thread: Re: Probably very easy to do, but for some reason...
- Index(es):
Relevant Pages
|