NYCPHP Meetup

[nycphp-talk] convert str array to int ???

CHUN-YIU LAM chun_lam at hotmail.com
Fri Mar 21 08:34:32 EST 2003


First, anything from a form is always a string, because there isn't anything 
that is past to your php script that says it is any other type.  Second, you 
can use "array_merge.






----Original Message Follows----
From: Tracy <tech_learner at yahoo.com>
Reply-To: talk at nyphp.org
To: NYPHP Talk <talk at nyphp.org>
Subject: [nycphp-talk] convert str array to int ???
Date: Thu, 20 Mar 2003 01:07:08 -0500
Received: from parsec.nyphp.org ([66.250.131.26]) by 
mc6-f37.law1.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Wed, 19 Mar 
2003 22:07:55 -0800
Received: from nyphp.org (parsec.nyphp.org [66.250.131.26])by 
parsec.nyphp.org (8.12.6/8.12.6) with ESMTP id h2K678JH090300for 
<chun_lam at hotmail.com>; Thu, 20 Mar 2003 01:07:54 -0500 (EST)(envelope-from 
null at nyphp.org)
X-Message-Info: JGTYoYF78jEHjJx36Oi8+Q1OJDRSDidP
Message-Id: <200303200607.h2K678JH090300 at parsec.nyphp.org>
X-Paralist-Archived: <http://nyphp.org/list/paralist_archive.php?L_mid=3532>
X-List-Software: Paralist 0.6
List-ID: <nyphptalk.nyphp.org>
List-Owner: <mailto:listmaster at nyphp.org>
List-Archive: <http://nyphp.org/list/paralist_archive.php?L_lid=2>
List-Subscribe: <http://nyphp.org/list/>
List-Unsubscribe: <http://nyphp.org/list/>
Organization: New York PHP
X-Mailer: Paramail 0.5
Return-Path: null at nyphp.org
X-OriginalArrivalTime: 20 Mar 2003 06:07:55.0906 (UTC) 
FILETIME=[0CA7AE20:01C2EEA7]

Hi,
i have a script which works with integers. i am taking the inputs from a 
form and now it defaults to string. a var_dump gives :

INPUTS :
array(2) {
   [0]=>
   array(2) {
     [0]=>
     string(1) "0"
     [1]=>
     string(1) "1"
   }
   [1]=>
   array(2) {
     [0]=>
     string(1) "1"
     [1]=>
     string(1) "1"
   }
}

but i need the values to be ints....

i tried :

foreach ($pieces as $k => $v) {
  $$k = $v;
  echo $k ."=". $v ."<br>";
//var_dump ($v);
  $cast = is_array ($v);
  if ($cast) {
   foreach ($v as $key => $val) {
    $$key = $val;
    echo $key ."=". $val ."<br>";

    $chk = is_int($val);
    echo "variable type : $chk <br>";
    if (!$chk) settype ($val,"integer");
   }
  }
}

but still i am not able to type juggle. i have missed something but i am 
unable to find out what. can someone plz identify what it is?
is there a better way, i am not sure i am coding in the right way...

also, i have two arrays, i want to merge them as :
new[0] = array1[0], array2[0], array2[1]
new[1] = array1[1], array2[1], array2[1]

how to do this, i am again not getting the results like expected.

Thz
Tracy


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Coming together is a beginning...
    keeping together is progress...
       working together is success !!!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


---------------------------------
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!


--- Unsubscribe at http://nyphp.org/list/ ---




_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail




More information about the talk mailing list