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

CHUN-YIU LAM chun_lam at
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>
Reply-To: talk at
To: NYPHP Talk <talk at>
Subject: [nycphp-talk] convert str array to int ???
Date: Thu, 20 Mar 2003 01:07:08 -0500
Received: from ([]) by with Microsoft SMTPSVC(5.0.2195.5600); Wed, 19 Mar 
2003 22:07:55 -0800
Received: from ( [])by (8.12.6/8.12.6) with ESMTP id h2K678JH090300for 
<chun_lam at>; Thu, 20 Mar 2003 01:07:54 -0500 (EST)(envelope-from 
null at
X-Message-Info: JGTYoYF78jEHjJx36Oi8+Q1OJDRSDidP
Message-Id: <200303200607.h2K678JH090300 at>
X-Paralist-Archived: <>
X-List-Software: Paralist 0.6
List-ID: <>
List-Owner: <mailto:listmaster at>
List-Archive: <>
List-Subscribe: <>
List-Unsubscribe: <>
Organization: New York PHP
X-Mailer: Paramail 0.5
Return-Path: null at
X-OriginalArrivalTime: 20 Mar 2003 06:07:55.0906 (UTC) 

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 :

array(2) {
   array(2) {
     string(1) "0"
     string(1) "1"
   array(2) {
     string(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.


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 ---

Add photos to your messages with MSN 8. Get 2 months FREE*.

More information about the talk mailing list