php-general Digest 30 Jun 2009 10:33:10 -0000 Issue 6203

Topics (messages 294723 through 294731):

Re: Named pair array from variable
        294723 by: Ashley Sheridan
        294724 by: Shawn McKenzie
        294725 by: Shawn McKenzie

Re: Best way to reinstate radio-button states from database?
        294726 by: Michael A. Peters

Re: guide me please
        294727 by: Michael A. Peters

Re: Does something like this exist?
        294728 by: Nathan Nobbe

Scope woe
        294729 by: Luke

Push an Array, Comma separated.
        294730 by: Louie Miranda
        294731 by: Richard Heyes

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On Mon, 2009-06-29 at 12:06 -0700, Mikey Knutson wrote:
> Is this even possible?  I'm building a string, properly formatted, to create 
> a named pair or associative array.   The string is fine, and when I use it 
> directly to create the array, all is well.  When I try to use the var to 
> create the array, I get an empty array (I think).  Huh?
> 
> Here is what I have:
> 
> $myString = "'username' => 'password' , 'mickey' => 'mouse' , 'donald' => 
> 'duck'";
> $myArray = array($myString);
> print ("array val: $myArray[username]");   // get an empty string here
> 
> 
> 
> 
What you're doing is assigning the string "'username' => 'password' ,
'mickey' => 'mouse' , 'donald' => 'duck'" to the first index of the
array. What you should be doing is assigning the elements one by one to
the array so that they have proper indexes.

Thanks
Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
Mikey Knutson wrote:
> Is this even possible?  I'm building a string, properly formatted, to create 
> a named pair or associative array.   The string is fine, and when I use it 
> directly to create the array, all is well.  When I try to use the var to 
> create the array, I get an empty array (I think).  Huh?
> 
> Here is what I have:
> 
> $myString = "'username' => 'password' , 'mickey' => 'mouse' , 'donald' => 
> 'duck'";
> $myArray = array($myString);
> print ("array val: $myArray[username]");   // get an empty string here
> 
> 
> 

AFAIK you can't do what you're showing.  This will work, but is not advised:

    eval('$myArray = array(' . $myString . ');');
    print ("array val: $myArray[username]");   // array val: password

Why are you needing to store the array indexes and values in a string
like this?  Maybe we can give you an alternative approach.

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
Shawn McKenzie wrote:
> Mikey Knutson wrote:
>> Is this even possible?  I'm building a string, properly formatted, to create 
>> a named pair or associative array.   The string is fine, and when I use it 
>> directly to create the array, all is well.  When I try to use the var to 
>> create the array, I get an empty array (I think).  Huh?
>>
>> Here is what I have:
>>
>> $myString = "'username' => 'password' , 'mickey' => 'mouse' , 'donald' => 
>> 'duck'";
>> $myArray = array($myString);
>> print ("array val: $myArray[username]");   // get an empty string here
>>
>>
>>
> 
> AFAIK you can't do what you're showing.  This will work, but is not advised:
> 
>     eval('$myArray = array(' . $myString . ');');
>     print ("array val: $myArray[username]");   // array val: password
> 
> Why are you needing to store the array indexes and values in a string
> like this?  Maybe we can give you an alternative approach.
> 

Unless I'm way off you might like serialize()


-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
Rob Gould wrote:
I have a webpage which allows people to log in and make selections with radio buttons and hit SUBMIT and saves the data from those radio buttons to a mySQL database.

However, I'm finding that I also need the ability to allow a user to log back in at a later date (or even on a different computer), and pull up that survey again, with each of the 50-something radio-buttons back in the positions in which they were last saved.

Surely there's a best-case-method for doing this type of thing (saving large numbers of radio-button-group settings to mySQL and pulling them back again later). Any advice is greatly appreciated. Perhaps there's a jQuery-way to retrieve all the radio-button group settings as an array and save it and pull it back again?
Or perhaps a PHP-specific method - - - I'm fine with either.




Generate your radio list via php.
When the value grabbed from database matches the button value, add a selected="selected" to the radio input.

Works for me.

--- End Message ---
--- Begin Message ---
Suresh Gupta VG wrote:
Hi List,
I am newb to this PHP. I am using "AIX Version 5.3" OS and "PHP version 4.3.9" by default version and "Oracle Application Server 10g Release 2". Configured properly and I am getting the phpinfo.php on browser properly. But when I write my own code for php, it is just displaying the code but it is not running the php code. Is there any mistake in configuring the apache or else where? pls guide me. With thanks and Regards, Suresh.G

What web server does Oracle use as part of their application server?
It may simply be a matter of the php module not being loaded when the web server starts.

But, as others have stated, you probably want to install a much fresher version of php, for a large number reasons.
--- End Message ---
--- Begin Message ---
On Mon, Jun 29, 2009 at 2:12 PM, Christoph Boget
<christoph.bo...@gmail.com>wrote

> I'm wondering if there isn't something out there that crawls through
> your codebase and generates a map of (any of) the following:
>
> * What files are include in which scripts


the inclued extension

http://pecl.php.net/package/inclued

* The relationships between defined classes (eg A extends B)
> * What other classes are utilized by which classes (eg, instantiation)
>

doxygen - i like it way more than php documentor or w/e its called..

-nathan

--- End Message ---
--- Begin Message ---
Hello again guys,

I was wondering the best way to tackle the following problem:

I've got a class, containing a property which is another object. So from
outside I should be able to do
$firstobject->propertycontainingobject->methodinsidethatobject();

The $firstobject variable is in the global namespace (having been made with
$firstobject = new FirstObject;), and I'm having a problem that I'm sure
many people have when accessing it inside another class, so:

class otherObject
{
static function messwithotherthings ()
{
$firstobject->propertycontainingobject->methodinsidethatobject();
}
}

But $firstobject is blank, which makes sense because in there it is pointing
to the local variable within the method.

To solve this, I could add 'global $firstobject' inside every method, but
this is very redundant and boring. I've tried a couple of things like
adding:

private $firstobject = $GLOBALS['firstobject'];

But apparently that's bad syntax. I was just wondering the best way to get
around this?

Thanks a lot for your help,

-- 
Luke Slater
:O)

--- End Message ---
--- Begin Message ---
GPS Administrative Page v2.3.12 (BETA)My array:
Array ( [0] => Demo2.txt [1] => Demo.txt [2] => Demo.txt )

How could I push the values as:

-> Demo2.txt, Demo.txt, Demo.txt?

Not sure which approach is good.

$saveFiles = array();
array_push($saveFiles, $ufName);

Help
--
Louie Miranda (lmira...@gmail.com)
http://www.louiemiranda.net

Quality Web Hosting - www.axishift.com
Pinoy Web Hosting, Web Hosting Philippines

--- End Message ---
--- Begin Message ---
> My array:
> Array ( [0] => Demo2.txt [1] => Demo.txt [2] => Demo.txt )
>
> How could I push the values as:
>
> -> Demo2.txt, Demo.txt, Demo.txt?
>
> Not sure which approach is good.
>
> $saveFiles = array();
> array_push($saveFiles, $ufName);

you could use array_push(), or the shorter syntax:

 o array_push();

array_push($myArr, 'Demo2.txt', 'Demo.txt', 'Demo.txt');

 o Shorter syntax:

$myArr[] = 'Demo2.txt';
$myArr[] = 'Demo.txt';
$myArr[] = 'Demo.txt';

-- 
Richard Heyes
HTML5 graphing: RGraph (www.rgraph.net - updated 20th June)
PHP mail: RMail (www.phpguru.org/rmail)
PHP datagrid: RGrid (www.phpguru.org/rgrid)
PHP Template: RTemplate (www.phpguru.org/rtemplate)
PHP SMTP: http://www.phpguru.org/smtp

--- End Message ---

Reply via email to