|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 10 Sep 2003 04:22:16 -0000 Issue 2288
php-general-digest-help
lists.php.net
Date: Tue Sep 09 2003 - 23:22:16 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 10 Sep 2003 04:22:16 -0000 Issue 2288
Topics (messages 162087 through 162137):
PREG-pattern, help needed
162087 by: Tobias Talltorp
162093 by: Armand Turpel
Dynamic Multi Dimensional Arrays
162088 by: Bobby Patel
162090 by: Bobby Patel
162091 by: Tom Rogers
162092 by: Brad Pauly
162094 by: Bobby Patel
162095 by: Bobby Patel
Is there an issue using sessions with IE/Mac?
162089 by: Matt MacLeod
162096 by: Richard Baskett
162099 by: Lowell Allen
162100 by: Richard Baskett
Re: PHP and Apache
162097 by: jsWalter
Installing PHP with MySQL RPM version
162098 by: Mark McCulligh
162101 by: Ray Hunter
162102 by: Mark McCulligh
162104 by: Ray Hunter
162105 by: Mark McCulligh
162106 by: Brad Pauly
Brainiacs please help! PostgreSQL and foreach() problem
162103 by: Peter Sharpe
162137 by: Raditha Dissanayake
Help with Displaying RSS feed links
162107 by: Frank Miller
162108 by: Alister
162110 by: Matt Matijevich
Some xml to array
162109 by: Bc. Radek Krejèa
162129 by: Raditha Dissanayake
str_replace question
162111 by: Al
162112 by: Wouter van Vliet
162124 by: Robert Cummings
maillist php manger/interface
162113 by: Boulytchev, Vasiliy
162127 by: zavaboy
Re: countries,states and cities
162114 by: Chris W. Parker
162115 by: Chris Shiflett
162117 by: Kevin Stone
A complete EXIF extension?
162116 by: Greg Militello
divide
162118 by: phpu
162119 by: phpu
162120 by: phpu
162122 by: Gabriel Guzman
argg - new install of php 4.3.3 on iis/w2k - post variables are empty
162121 by: Tom H
Multiple Forms
162123 by: Dan Anderson
162125 by: Robert Cummings
Explode and multple lines
162126 by: Sweet T
162128 by: David
Re: Encrypt/Serialize Source Code for Sale
162130 by: Jason Sheets
Re: Session Variables in a Class
162131 by: Curt Zirzow
SID set or unset?
162132 by: Jean-Christian IMbeault
Re: Lost Connection to MySQL server during query
162133 by: Curt Zirzow
Re: Setting execution time for a loop
162134 by: Curt Zirzow
gforge
162135 by: electroteque
Re: count() & numerical arrays....
162136 by: Curt Zirzow
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
I need help with a preg-pattern for preg_replace_callback().
I need to match <td(+all properties)> and replace them with <td
id=$counter>.
This is as far as I have come in my code:
<?php
$html = '<table border=1 id="myTable">
<tr>
<td>
<table border=1>
<tr>
<td width=20>tabell2 cell1</td>
<td width=40>tabell2 cell2</td>
</tr>
</table>
</td>
<td>första cell i rad två</td>
<td>Detta är den sista</td>
</tr>
</table>';
$counter = 0;
function bla($matches) {
global $counter;
$counter++;
return "<td id=\"theId".$counter."\">";
}
// this pattern is all wrong, since it matches and replaces all tags
echo preg_replace_callback("|(<[td][^>]+>)|i", "bla", $html);
?>
Any thoughts?
// Tobias
attached mail follows:
Hi,
What about:
$string = preg_replace("/(<td)[^>]*/","\\1 id={$counter}",$string);
atur
----- Original Message -----
From: "Tobias Talltorp" <tobias
talltorp.com>
To: <php-general
lists.php.net>
Sent: Tuesday, September 09, 2003 6:35 PM
Subject: [PHP] PREG-pattern, help needed
> I need help with a preg-pattern for preg_replace_callback().
>
> I need to match <td(+all properties)> and replace them with <td
> id=$counter>.
>
> This is as far as I have come in my code:
>
> <?php
>
> $html = '<table border=1 id="myTable">
> <tr>
> <td>
> <table border=1>
> <tr>
> <td width=20>tabell2 cell1</td>
> <td width=40>tabell2 cell2</td>
> </tr>
> </table>
> </td>
> <td>första cell i rad två</td>
> <td>Detta är den sista</td>
> </tr>
> </table>';
>
> $counter = 0;
> function bla($matches) {
> global $counter;
> $counter++;
> return "<td id=\"theId".$counter."\">";
> }
>
>
> // this pattern is all wrong, since it matches and replaces all tags
> echo preg_replace_callback("|(<[td][^>]+>)|i", "bla", $html);
>
> ?>
>
>
> Any thoughts?
> // Tobias
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
attached mail follows:
Hello Everyone,
I want to emulate session objects (as opposed to variables). I stumbled
upon creating multi-dimensional arrays, so I can do this:
$name = 'Bob';
$year = '2003';
$HTTP_SESSION_VARS[$user][$year] = 'registered';
which gives $HTTP_SESSION_VARS['Bob']['2003'] = 'registered';
but I want to append an options array in this so what I want is:
$options = array (
'income' => 10000,
'age' => 25
);
$HTTP_SESSION_VARS[$user][$options] = 'registered';
which gives:
$HTTP_SESSION_VARS['Bob'][ [income]=10000, [age]=25 ] = 'registered';
but this doesn't work. Is there any way I can have "objects" saved in
sessions?
Bobby
attached mail follows:
Hello Everyone,
I want to emulate session objects (as opposed to variables). I stumbled
upon creating multi-dimensional arrays, so I can do this:
$name = 'Bob';
$year = '2003';
$HTTP_SESSION_VARS[$user][$year] = 'registered';
which gives $HTTP_SESSION_VARS['Bob']['2003'] = 'registered';
but I want to append an options array in this so what I want is:
$options = array (
'income' => 10000,
'age' => 25
);
(Where the $options array is created dynamically from passed POST data).
$HTTP_SESSION_VARS[$user][$options] = 'registered';
which gives:
$HTTP_SESSION_VARS['Bob'][ [income]=10000, [age]=25 ] = 'registered';
but this doesn't work. Is there any way I can have "objects" saved in
sessions?
Bobby
attached mail follows:
Hi,
Tuesday, September 9, 2003, 2:19:28 PM, you wrote:
BP> Hello Everyone,
BP> I want to emulate session objects (as opposed to variables). I stumbled
BP> upon creating multi-dimensional arrays, so I can do this:
BP> $name = 'Bob';
BP> $year = '2003';
BP> $HTTP_SESSION_VARS[$user][$year] = 'registered';
BP> which gives $HTTP_SESSION_VARS['Bob']['2003'] = 'registered';
BP> but I want to append an options array in this so what I want is:
BP> $options = array (
BP> 'income' => 10000,
BP> 'age' => 25
BP> );
BP> $HTTP_SESSION_VARS[$user][$options] = 'registered';
BP> which gives:
BP> $HTTP_SESSION_VARS['Bob'][ [income]=10000, [age]=25 ] = 'registered';
BP> but this doesn't work. Is there any way I can have "objects" saved in
BP> sessions?
BP> Bobby
you would have to give $user another key value
$options = array('income'=>10000.'age'=>25);
$HTTP_SESSION_VARS[$user] = $options;
$HTTP_SESSION_VARS[$user]['status'] = 'registered';
also in these cases print_r($HTTP_SESSION_VARS[$user]) can be your
friend.
--
regards,
Tom
attached mail follows:
Bobby Patel wrote:
> Hello Everyone,
>
> I want to emulate session objects (as opposed to variables). I stumbled
> upon creating multi-dimensional arrays, so I can do this:
> $name = 'Bob';
> $year = '2003';
>
> $HTTP_SESSION_VARS[$user][$year] = 'registered';
> which gives $HTTP_SESSION_VARS['Bob']['2003'] = 'registered';
>
> but I want to append an options array in this so what I want is:
>
> $options = array (
> 'income' => 10000,
> 'age' => 25
> );
>
> $HTTP_SESSION_VARS[$user][$options] = 'registered';
> which gives:
> $HTTP_SESSION_VARS['Bob'][ [income]=10000, [age]=25 ] = 'registered';
>
> but this doesn't work. Is there any way I can have "objects" saved in
> sessions?
There is, but I am not sure that is what you want. The reason you are
getting the above result is because you are using $object (which is an
array) as a key. Do you want an array element that holds the $options array?
$HTTP_SESSION_VARS[$user]['options'] = $options;
You could then add elements to this array like this:
$HTTP_SESSION_VARS[$user]['options']['registered'] = 1;
Is that what you are trying to do?
- Brad
attached mail follows:
Brad Pauly wrote:
>
> $HTTP_SESSION_VARS[$user]['options'] = $options;
yes this is what I wanted.
>
> You could then add elements to this array like this:
>
> $HTTP_SESSION_VARS[$user]['options']['registered'] = 1;
>
> Is that what you are trying to do?
>
> - Brad
I will try this out and see what happens.
Thank you Tom and Brad.
attached mail follows:
Brad Pauly wrote:
>
> $HTTP_SESSION_VARS[$user]['options'] = $options;
yes this is what I wanted.
>
> You could then add elements to this array like this:
>
> $HTTP_SESSION_VARS[$user]['options']['registered'] = 1;
>
> Is that what you are trying to do?
>
> - Brad
I will try this out and see what happens.
Thank you Tom and Brad.
attached mail follows:
I've built a log in system which sets the user's id as a session if
succesfully logged in. However, a user on IE5/Mac tells me that the site
logs her out even though she has entered the correct login details. I
have tried using her details on Firebird/Windows and have had no problems.
Are there any known issues using php sesisons with IE5/Mac?
Cheers,
Matt
attached mail follows:
on 9/9/03 9:33 AM, Matt MacLeod at matt
bigbarn.co.uk wrote:
> I've built a log in system which sets the user's id as a session if
> succesfully logged in. However, a user on IE5/Mac tells me that the site
> logs her out even though she has entered the correct login details. I
> have tried using her details on Firebird/Windows and have had no problems.
>
> Are there any known issues using php sesisons with IE5/Mac?
>
> Cheers,
> Matt
Not that I know of.. I have written most all my applications using IE5 on
the Mac as my primary browser and they all work great.. And now that I use
Safari they still work great.. So there is something wrong with the way
your cookies are being set I believe.. or some other problem.. because IE5
for mac can definitely use and work with sessions..
Cheers!
Rick
"We should be taught not to wait for inspiration to start a thing. Action
always generates inspiration. Inspiration seldom generates action." - Frank
Tibolt
attached mail follows:
> I've built a log in system which sets the user's id as a session if
> succesfully logged in. However, a user on IE5/Mac tells me that the site
> logs her out even though she has entered the correct login details. I
> have tried using her details on Firebird/Windows and have had no problems.
>
> Are there any known issues using php sesisons with IE5/Mac?
For what it's worth (which may not be much), I've heard reports of problems
with IE5.2 in OSX when used with Entourage. A colleague's session was
failing after checking email with Entourage, and he said Microsoft confirmed
the problem. However -- I've since gone to OSX and can't duplicate the
problem on my system.
--
Lowell Allen
attached mail follows:
on 9/9/03 11:46 AM, Lowell Allen at la
lowellallen.com wrote:
>> I've built a log in system which sets the user's id as a session if
>> succesfully logged in. However, a user on IE5/Mac tells me that the site
>> logs her out even though she has entered the correct login details. I
>> have tried using her details on Firebird/Windows and have had no problems.
>>
>> Are there any known issues using php sesisons with IE5/Mac?
>
> For what it's worth (which may not be much), I've heard reports of problems
> with IE5.2 in OSX when used with Entourage. A colleague's session was
> failing after checking email with Entourage, and he said Microsoft confirmed
> the problem. However -- I've since gone to OSX and can't duplicate the
> problem on my system.
Ah yes there was a huge problem with this.. basically every time Entourage
went and checked your mail.. or a ToDo, Calendar alert happened the
preferences that Entourage and IE shared (don't ask me why) we're
overwritten.. thus deleting any session info, etc that might have been in
the cookies in IE. Im not sure if they fixed it yet.. but if you couldn¹t
duplicate the problem.. then it sounds like they have. I finally got so
frustrated I went to other browsers.. and now am on Safari.. too bad IE,
which is ok since MS does not support the Mac version anymore anyways.
Cheers!
Rick
"Today I begin to understand what love must be, if it exists.... When we are
parted, we each feel the lack of the other half of ourselves. We are
incomplete like a book in two volumes of which the first has been lost. That
is what I imagine love to be: incompleteness in absence." - Goncourt
attached mail follows:
I have a complete setup and testing procedure for windows class machines.
Hope it can help you.
www.torres.ws/dev/php
Walter
attached mail follows:
I am trying to ./configure PHP 4.3.3 on a system that already has MySQL
4.0.14 on it.
In the configure line --with-mysql=/path/to/mysql were is the path for RPM
versions of MySQL. I have search the computer but it looks like the mysql
files are all over the place. Database files are in /var/lib/mysql BIN
files are in /usr/bin/, etc...
If you install MySQL from a RPM what path do you put in the PHP configure
line
Thanks,
Mark.
attached mail follows:
> In the configure line --with-mysql=/path/to/mysql were is the path for RPM
> versions of MySQL. I have search the computer but it looks like the mysql
> files are all over the place. Database files are in /var/lib/mysql BIN
> files are in /usr/bin/, etc...
use --with-mysql or --with-mysql-sock
example:
./configure --with-mysql
./configure --with-mysql-sock=/var/lib/mysql/mysql.sock
hth
--
BigDog
attached mail follows:
Thanks,
If you just use --with-mysql it will use PHP's built-in mysql client lib
3.23.49, but I have MySQL 4.0.14 installed. Won't this make a difference. I
want to make sure PHP is compiled this the right libraries for MySQL.
Mark.
"Ray Hunter" <bigdog
venticon.com> wrote in message
news:1063133321.11538.8.camel
bigdog.info.trw.com...
> > In the configure line --with-mysql=/path/to/mysql were is the path for
RPM
> > versions of MySQL. I have search the computer but it looks like the
mysql
> > files are all over the place. Database files are in /var/lib/mysql
BIN
> > files are in /usr/bin/, etc...
>
> use --with-mysql or --with-mysql-sock
>
> example:
>
> ./configure --with-mysql
> ./configure --with-mysql-sock=/var/lib/mysql/mysql.sock
>
> hth
>
> --
> BigDog
attached mail follows:
mark,
from what i understand of the configuration script it will go out and
look in various locations for the mysql libraries. If you want to
specify something then I would suggest using the --with-mysql-sock and
pass the socket file. I like to use the socket file and have always had
great success with it even for mysql 4.0
--
BigDog
On Tue, 2003-09-09 at 12:59, Mark McCulligh wrote:
> Thanks,
>
> If you just use --with-mysql it will use PHP's built-in mysql client lib
> 3.23.49, but I have MySQL 4.0.14 installed. Won't this make a difference. I
> want to make sure PHP is compiled this the right libraries for MySQL.
>
> Mark.
>
>
> "Ray Hunter" <bigdog
venticon.com> wrote in message
> news:1063133321.11538.8.camel
bigdog.info.trw.com...
> > > In the configure line --with-mysql=/path/to/mysql were is the path for
> RPM
> > > versions of MySQL. I have search the computer but it looks like the
> mysql
> > > files are all over the place. Database files are in /var/lib/mysql
> BIN
> > > files are in /usr/bin/, etc...
> >
> > use --with-mysql or --with-mysql-sock
> >
> > example:
> >
> > ./configure --with-mysql
> > ./configure --with-mysql-sock=/var/lib/mysql/mysql.sock
> >
> > hth
> >
> > --
> > BigDog
attached mail follows:
Ok,
when I compiled with --with-mysql only, phpinfo() said:
Client API version: 3.23.49
I will recompile PHP with --with-mysql-sock instead.
I want to make sure PHP is using the right MySQL Client version.
Thanks,
Mark.
"Ray Hunter" <bigdog
venticon.com> wrote in message
news:1063134537.11397.16.camel
bigdog.info.trw.com...
> mark,
>
> from what i understand of the configuration script it will go out and
> look in various locations for the mysql libraries. If you want to
> specify something then I would suggest using the --with-mysql-sock and
> pass the socket file. I like to use the socket file and have always had
> great success with it even for mysql 4.0
>
> --
> BigDog
>
>
> On Tue, 2003-09-09 at 12:59, Mark McCulligh wrote:
> > Thanks,
> >
> > If you just use --with-mysql it will use PHP's built-in mysql client lib
> > 3.23.49, but I have MySQL 4.0.14 installed. Won't this make a
difference. I
> > want to make sure PHP is compiled this the right libraries for MySQL.
> >
> > Mark.
> >
> >
> > "Ray Hunter" <bigdog
venticon.com> wrote in message
> > news:1063133321.11538.8.camel
bigdog.info.trw.com...
> > > > In the configure line --with-mysql=/path/to/mysql were is the path
for
> > RPM
> > > > versions of MySQL. I have search the computer but it looks like the
> > mysql
> > > > files are all over the place. Database files are in /var/lib/mysql
> > BIN
> > > > files are in /usr/bin/, etc...
> > >
> > > use --with-mysql or --with-mysql-sock
> > >
> > > example:
> > >
> > > ./configure --with-mysql
> > > ./configure --with-mysql-sock=/var/lib/mysql/mysql.sock
> > >
> > > hth
> > >
> > > --
> > > BigDog
attached mail follows:
Mark McCulligh wrote:
> when I compiled with --with-mysql only, phpinfo() said:
> Client API version: 3.23.49
>
> I will recompile PHP with --with-mysql-sock instead.
I don't think this will change the client version. It is my
understanding that this will just tell the client to look in a specific
place for the socket file.
> I want to make sure PHP is using the right MySQL Client version.
I think you will need to specify the location using --with-mysql=[dir].
It is just a guess, but try --with-mysql=/usr
If you can't find where it is, one thing that might be worth considering
is whether or not you need the 4.0 client lib. Take a look at this link:
http://www.mysql.com/doc/en/Upgrading-from-3.23.html
- Brad
attached mail follows:
I have a database full of names. each name could be linked to any number of
sub-names, each sub-name could be linked to any number of sub-sub-names, to
infinity (unlikely but possible).
I need to iterate through this nest of names starting with a main name; lets
call the main name Peter. Peter could have John, Tim & Mike working for him.
Tim could have Greg working for him.
function select_names($current_top_name){
global $dbh;
$sql = "
SELECT
name_id_fk
FROM
name_relation
WHERE
top_name_id_fk = '".$current_top_name."'
";
$rs = pg_query($dbh, $sql);
if(($num_rows = pg_num_rows($rs)) > 0){
for($i=0;$i<$num_rows;$i++){
$row = pg_fetch_row($rs, $i, PGSQL_ASSOC);
$associated_names[] = $row['name_id_fk'];
}
pg_free_result($rs);
} // end if(($num_rows = pg_num_rows($rs)) > 0)
return $associated_names;
} // end function select_names()
$current_top_name = 'Peter';
while(!$stop){
$assoc_names = select_names($current_top_name);
foreach($assoc_names as $key => $val){
print($val);
$more_assoc_names = select_names($val);
if($more_assoc_names){
ARG HELP IM NOT SMART ENOUGH
}
} // end while(!$stop)
} // end foreach($assoc_names as $key => $val)
attached mail follows:
Hi,
It's not very clear what you are trying to do. From what i understand
from your mail, i think a recursive call to select_names would be the
ideal solution. In these scenario you call select_names() once and from
within the function you call select_name() again for the each of the
matches on the first level.
You should be aware of the obvious drawback of recursive calls: memory
consumption. If your tree strecthes to infinity as you feel it migh, you
will get a stack overflow. :-)
Peter Sharpe wrote:
>I have a database full of names. each name could be linked to any number of
>sub-names, each sub-name could be linked to any number of sub-sub-names, to
>infinity (unlikely but possible).
>
>I need to iterate through this nest of names starting with a main name; lets
>call the main name Peter. Peter could have John, Tim & Mike working for him.
>Tim could have Greg working for him.
>
>function select_names($current_top_name){
>global $dbh;
>
>$sql = "
>SELECT
> name_id_fk
>FROM
> name_relation
>WHERE
> top_name_id_fk = '".$current_top_name."'
>";
>$rs = pg_query($dbh, $sql);
>
>if(($num_rows = pg_num_rows($rs)) > 0){
>
>for($i=0;$i<$num_rows;$i++){
>$row = pg_fetch_row($rs, $i, PGSQL_ASSOC);
>$associated_names[] = $row['name_id_fk'];
>}
>
>pg_free_result($rs);
>
>} // end if(($num_rows = pg_num_rows($rs)) > 0)
>
>return $associated_names;
>
>} // end function select_names()
>
>$current_top_name = 'Peter';
>
>while(!$stop){
>
>$assoc_names = select_names($current_top_name);
>
>foreach($assoc_names as $key => $val){
>print($val);
>$more_assoc_names = select_names($val);
>if($more_assoc_names){
>ARG HELP IM NOT SMART ENOUGH
>}
>
>} // end while(!$stop)
>
>} // end foreach($assoc_names as $key => $val)
>
>
>
--
http://www.radinks.com/upload
Drag and Drop File Uploader.
attached mail follows:
Hello all,
I'm working on an entry page where I would like to show some of the
current headlines from technology websites. I've been following and
pretty much understand the article on devshed
http://www.devshed.com/Server_Side/PHP/PHPRDF/page1.html Plugging RDF
content into your Website. From what I gather from the article is that
he uses a foreach loop to display the Title, link and description which
could be anywhere from 5 to 15 links. I only have room on my page for 3
and then I plan on putting a more link taking visitors to a page where
I'll have more room.
I was reading in the Welling/Thomson book about converting a foreach
loop into another loop. Here is the original foreach loop and then what
I was trying to convert it to:
foreach ($items as $item)
{
echo "<tr><td><a href=" . $item["link"] . ">" . $item["title"] .
"</a><br>" . $item["description"] . "</td></tr>"; }
//**********************************************************************
*
for ($row=0; $row<2; $row++)
{
while (list ( $key, $value) = each ($items[$row]))
{
echo "<tr><td><a href=" . $item["link"] . ">" . $item["title"] .
"</a><br>" . $item["description"] . "</td></tr>";
}
}
Can anyone point me in the right direction? Right now I don't get an
error but I also don't get any text or results.
Thanks - Frank
Here is the code from the original article:
//****************************************
<html>
<head>
<basefont face="Verdana">
</head>
<body>
<table border="0" cellspacing="5" cellpadding="5">
<tr>
<td><b>New releases on freshmeat.net today:</b></td>
</tr>
<?php
// XML file
$file = "http://www.freshmeat.net/backend/fm-releases.rdf";
// set up some variables for use by the parser
$currentTag = "";
$flag = "";
$count = 0;
// this is an associative array of channel data with keys
("title","link","description")
$channel = array();
// this is an array of arrays, with each array element representing an
<item>
// each outer array element is itself an associative array
// with keys ("title", "link", "description")
$items = array();
// opening tag handler
function elementBegin($parser, $name, $attributes)
{
global $currentTag, $flag;
$currentTag = $name;
// set flag if entering <channel> or <item> block
if ($name == "ITEM")
{
$flag = 1;
}
else if ($name == "CHANNEL")
{
$flag = 2;
}
}
// closing tag handler
function elementEnd($parser, $name)
{
global $currentTag, $flag, $count;
$currentTag = "";
// set flag if exiting <channel> or <item> block
if ($name == "ITEM")
{
$count++;
$flag = 0;
}
else if ($name == "CHANNEL")
{
$flag = 0;
}
}
// character data handler
function characterData($parser, $data)
{
global $currentTag, $flag, $items, $count, $channel;
$data = trim(htmlspecialchars($data));
if ($currentTag == "TITLE" || $currentTag == "LINK" ||
$currentTag == "DESCRIPTION")
{
// add data to $channels[] or $items[] array
if ($flag == 1)
{
$items[$count][strtolower($currentTag)] .=
$data;
}
else if ($flag == 2)
{
$channel[strtolower($currentTag)] .= $data;
}
}
}
// create parser
$xp = xml_parser_create();
// set element handler
xml_set_element_handler($xp, "elementBegin", "elementEnd");
xml_set_character_data_handler($xp, "characterData");
xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, TRUE);
xml_parser_set_option($xp, XML_OPTION_SKIP_WHITE, TRUE);
// read XML file
if (!($fp = fopen($file, "r")))
{
die("Could not read $file");
}
// parse data
while ($xml = fread($fp, 4096))
{
if (!xml_parse($xp, $xml, feof($fp)))
{
die("XML parser error: " .
xml_error_string(xml_get_error_code($xp)));
}
}
// destroy parser
xml_parser_free($xp);
// now iterate through $items[] array
// and print each item as a table row
foreach ($items as $item)
{
echo "<tr><td><a href=" . $item["link"] . ">" . $item["title"] .
"</a><br>" . $item["description"] . "</td></tr>"; }
?>
</table>
</body>
</html>
//******************************************************************
Frank Miller
Computer Specialist and Webmaster
Texas A&M University-Texarkana
2600 N. Robison Rd
Texarkana, Texas 75501
Office 165
Phone (903)223-3156 (2*2*61*37017349)
Fax (903)223-3139
attached mail follows:
On Tue, 9 Sep 2003 15:35:48 -0500
"Frank Miller" <fmiller
tamut.edu> wrote:
> Hello all,
>
> I'm working on an entry page where I would like to show some of the
> current headlines from technology websites. I've been following and
> pretty much understand the article on devshed
> http://www.devshed.com/Server_Side/PHP/PHPRDF/page1.html Plugging RDF
> content into your Website. From what I gather from the article is that
> he uses a foreach loop to display the Title, link and description
> which could be anywhere from 5 to 15 links. I only have room on my
> page for 3 and then I plan on putting a more link taking visitors to a
> page where I'll have more room.
> Can anyone point me in the right direction? Right now I don't get an
> error but I also don't get any text or results.
<?php
// http://pear.php.net/manual/en/package.xml.xml-rss.example.php
require_once "XML/RSS.php";
$rss =& new XML_RSS("http://slashdot.org/slashdot.rdf");
$rss->parse();
echo "<h1>Headlines from <a href=\"http://slashdot.org\">Slashdot</a></h1>\n";
echo "<ul>\n";
>$i = 0;
foreach ($rss->getItems() as $item) {
> if ($i == 3)
> break;
echo "<li><a href=\"" . $item['link'] . "\">" . $item['title'] . "</a></li>\n";
$i++;
}
echo "</ul>\n";
?>
Done.
attached mail follows:
could you use this for your loop?
$sizeArr = sizeof($items);
for ($row=0; $row<$sizeArr; $row++)
{
echo "<tr><td><a href=" . $items[$row]['link'] . ">" .
$items[$row]['title'] .
"</a><br>" . $items[$row]['description'] . "</td></tr>";
}
attached mail follows:
Hello,
I have following xml file:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<response>
<result code="1000" >
<msg>Hello, how are you?</msg>
</result>
<resData>
<osobaUdaje:infData>
<osobaUdaje:jmeno>Radek Krejca</osobaUdaje:jmeno>
<osobaUdaje:jmenoAprijmeni>
<osobaUdaje:krestni>Radek</osobaUdaje:krestni>
<osobaUdaje:prijmeni>Krejca</osobaUdaje:prijmeni>
</osobaUdaje:jmenoAprijmeni>
<osobaUdaje:postalInfo type="postal">
<osobaUdaje:addr>
<osobaUdaje:street>Zizkova 226/3</osobaUdaje:street>
<osobaUdaje:city>Ceske Budejovice</osobaUdaje:city>
<osobaUdaje:zip>370 01</osobaUdaje:zip>
<osobaUdaje:country>cz</osobaUdaje:country>
</osobaUdaje:addr>
</osobaUdaje:postalInfo>
<osobaUdaje:email>radek.krejca
starnet.cz</osobaUdaje:email>
</osobaUdaje:infData>
</resData>
</response>
</epp>
I can make following assoc. aray:
msg => Hello, how are you?
jmeno => Radek Krejca
.
.
.
How I can do that?
Thanks Radek
--
Regards,
Bc. Radek Krejca
Starnet, s. r. o.
radek
ceskedomeny.cz
http://www.ceskedomeny.cz
http://www.skdomeny.com
http://www.starnet.cz
ICQ: 65895541
attached mail follows:
Hi,
Looks like a crash course is XML is in order :-) I suggest you take a
look at the xml parser functions in the manual. to start off with. Then
there are some good tutorials at w3schools.com
all the best
Bc. Radek Krejèa wrote:
>Hello,
>
> I have following xml file:
>
><?xml version="1.0" encoding="UTF-8" standalone="no"?>
><epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
><response>
><result code="1000" >
><msg>Hello, how are you?</msg>
></result>
><resData>
><osobaUdaje:infData>
><osobaUdaje:jmeno>Radek Krejca</osobaUdaje:jmeno>
><osobaUdaje:jmenoAprijmeni>
><osobaUdaje:krestni>Radek</osobaUdaje:krestni>
><osobaUdaje:prijmeni>Krejca</osobaUdaje:prijmeni>
></osobaUdaje:jmenoAprijmeni>
><osobaUdaje:postalInfo type="postal">
><osobaUdaje:addr>
><osobaUdaje:street>Zizkova 226/3</osobaUdaje:street>
><osobaUdaje:city>Ceske Budejovice</osobaUdaje:city>
><osobaUdaje:zip>370 01</osobaUdaje:zip>
><osobaUdaje:country>cz</osobaUdaje:country>
></osobaUdaje:addr>
></osobaUdaje:postalInfo>
><osobaUdaje:email>radek.krejca
starnet.cz</osobaUdaje:email>
></osobaUdaje:infData>
></resData>
></response>
></epp>
>
> I can make following assoc. aray:
>
> msg => Hello, how are you?
> jmeno => Radek Krejca
> .
> .
> .
>
> How I can do that?
>
> Thanks Radek
>
>
>
--
http://www.radinks.com/upload
Drag and Drop File Uploader.
attached mail follows:
I've got a simple expression "<quesxx> where "xx" is a number from 0 to 99.
I want to replace it with simply <ques>. That is, I want to remove the
numbers.
Will "str_replace" do it, or must I use ereg_replace?
I haven't figured out from reading the php manual on regular expression
how to do this simple thing.
Thanks....
attached mail follows:
$String = "<ques99>";
preg_replace('/*\<[a-z]+)[0-9]+(\>)/', '$1$2', $String);
will most likeley do.
Btw, does anybody know why preg_replace is adviced over ereg_replace in the
manual? .. and if ereg_replace doesn't have any advantages over
preg_replace, couldn't this function get depricated?
-> -----Oorspronkelijk bericht-----
-> Van: Al [mailto:news
ridersite.org]
-> Verzonden: dinsdag 9 september 2003 23:21
-> Aan: php-general
lists.php.net
-> Onderwerp: [PHP] str_replace question
->
->
-> I've got a simple expression "<quesxx> where "xx" is a number
-> from 0 to 99.
->
-> I want to replace it with simply <ques>. That is, I want to remove the
-> numbers.
->
-> Will "str_replace" do it, or must I use ereg_replace?
->
-> I haven't figured out from reading the php manual on regular expression
-> how to do this simple thing.
->
-> Thanks....
->
-> --
-> PHP General Mailing List (http://www.php.net/)
-> To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
I think (and don't quote me on this, and feel free to correct me :) that
preg_replace() is fast being based on perl regular expressions.
ereg_replace() however, follows the POSIX standard for regular
expression matching.
Cheers,
Rob.
On Tue, 2003-09-09 at 17:36, Wouter van Vliet wrote:
> $String = "<ques99>";
> preg_replace('/*\<[a-z]+)[0-9]+(\>)/', '$1$2', $String);
>
> will most likeley do.
>
> Btw, does anybody know why preg_replace is adviced over ereg_replace in the
> manual? .. and if ereg_replace doesn't have any advantages over
> preg_replace, couldn't this function get depricated?
>
> -> -----Oorspronkelijk bericht-----
> -> Van: Al [mailto:news
ridersite.org]
> -> Verzonden: dinsdag 9 september 2003 23:21
> -> Aan: php-general
lists.php.net
> -> Onderwerp: [PHP] str_replace question
> ->
> ->
> -> I've got a simple expression "<quesxx> where "xx" is a number
> -> from 0 to 99.
> ->
> -> I want to replace it with simply <ques>. That is, I want to remove the
> -> numbers.
> ->
> -> Will "str_replace" do it, or must I use ereg_replace?
> ->
> -> I haven't figured out from reading the php manual on regular expression
> -> how to do this simple thing.
> ->
> -> Thanks....
> ->
> -> --
> -> PHP General Mailing List (http://www.php.net/)
> -> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
.---------------------------------------------.
| Worlds of Carnage - http://www.wocmud.org |
:---------------------------------------------:
| Come visit a world of myth and legend where |
| fantastical creatures come to life and the |
| stuff of nightmares grasp for your soul. |
`---------------------------------------------'
attached mail follows:
Ladies and Gents,
I need the following:
1. A online place for people to subscribe to mailing list.
2. A online place to unsibscribe from a mailing list.
3. Several admins for different mailing lists.
4. mysql integration.
What do you guys use? Any free software out there? I have reviewed
about a dozen, ready to pay for one. No time to develop.
Vasiliy Boulytchev
Colorado Information Technologies Inc.
(719) 473-2800 x15
<http://coinfotech.com/>
attached mail follows:
I have been thinking on developing one for some time now.
I can make one for free for you, I also have a friend that wants one too.
It may take me a week or two, when do you need it?
If you're willing to wait 3 weeks max, I can make it for free.
I can even put it in your site if you want.
I'm going to work on it now so incase you want it.
I will not have power on the 10th or 11th due to electrical work.
I'll tell you what, you email me for anything regarding this project.
My email: zavaboydesigns
ivitek.com
"Vasiliy Boulytchev" <vboulytchev
coinfotech.com> wrote in message
news:1958DE295D9656499ECAAD3642822DE0383141
willow.office.coinfotech.com...
Ladies and Gents,
I need the following:
1. A online place for people to subscribe to mailing list.
2. A online place to unsibscribe from a mailing list.
3. Several admins for different mailing lists.
4. mysql integration.
What do you guys use? Any free software out there? I have reviewed
about a dozen, ready to pay for one. No time to develop.
Vasiliy Boulytchev
Colorado Information Technologies Inc.
(719) 473-2800 x15
<http://coinfotech.com/>
attached mail follows:
Augusto Cesar Castoldi <mailto:accastoldi
yahoo.com.br>
on Monday, September 08, 2003 4:16 PM said:
> where can I download a database with all countries and
> states and cities?
I don't know but I would also be interested in this!!
> like:
> http://www.datingplace.com/servlet/NewRegistration
What? No North Korea? ;)
Chris.
attached mail follows:
> where can I download a database with all countries and
> states and cities?
http://www.maxmind.com/
That's a good open source one with APIs for just about everything, including an
Apache module that you can use for real-time queries even under significant
load.
Hope that helps.
Chris
=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/
attached mail follows:
"Chris W. Parker" <cparker
swatgear.com> wrote in message
news:001BD19C96E6E64E8750D72C2EA0ECEE2B8022
ati-ex-01.ati.local...
Augusto Cesar Castoldi <mailto:accastoldi
yahoo.com.br>
on Monday, September 08, 2003 4:16 PM said:
> where can I download a database with all countries and
> states and cities?
I don't know but I would also be interested in this!!
> like:
> http://www.datingplace.com/servlet/NewRegistration
What? No North Korea? ;)
Chris.
--------------------------------------
The world is a big place. To get you started here's the 2000 US Census
data. The file you want is the one labled 'Places.zip'. The schema is
available on the page but I've posted it below for convenience sake..
http://www.census.gov/geo/www/gazetteer/places2k.html
a.. Columns 1-2: United States Postal Service State Abbreviation
b.. Columns 3-4: State Federal Information Processing Standard (FIPS) code
c.. Columns 5-9: Place FIPS Code
d.. Columns 10-73: Name
e.. Columns 74-82: Total Population (2000)
f.. Columns 83-91: Total Housing Units (2000)
g.. Columns 92-105: Land Area (square meters) - Created for statistical
purposes only.
h.. Columns 106-119: Water Area(square meters) - Created for statistical
purposes only.
i.. Columns 120-131: Land Area (square miles) - Created for statistical
purposes only.
j.. Columns 132-143: Water Area (square miles) - Created for statistical
purposes only.
k.. Columns 144-153: Latitude (decimal degrees) First character is blank
or "-" denoting North or South latitude respectively
l.. Columns 154-164: Longitude (decimal degrees) First character is blank
or "-" denoting East or West longitude respectively
Enjoy!
Kevin
attached mail follows:
Hey all,
I've been dealing with EXIF data in images for a while now. Reading
in PHP is available, however editing, or creating EXIF entries doesn't
exist.
I am going to work on a set of classes to interphase with libexif a C
package at:
http://sourceforge.net/projects/libexif/
The package itself, appears to have a license compatible with PHP
(MIT license), and I beleive would make a great addition to PHP's
graphics library. Currently industry standards use EXIF all over the
place, and very few languages (from what I have found) have really good
support for EXIF.
Integration to PHP would be ideal. Say you resize an image using GD,
currently the EXIF data that previously existed with your image is
gone. Now you could rewrite information back into your image. EXIF
also always for user defined feilds, which would mean I could attach a
description directly to an image saving the use of a database or other
datasource.
I am not a C coder, and thus I don't fansy myself a writer of
PHP/PECL extensions. I was wondering if support for this kind of action
is scheduled? If not, is there a chance it might be? I am willing to
offer my own assistance in the matter, but I have zero experience in
this realm. Regaurdless of weather a PHP/PECL extension is created,
I am planning to write abstraction for using this lib commandline. But
ideally for speed, and integration/permissions reasons this would exist
as a PHP/PECL extension.
Thoughts?
-Greg Militello
<?php
/**
* show email
*/
print "junk" . "
" . "st"."eti" . "." . "com";
?>
attached mail follows:
Hello,
I'm new in php and i've got allready a problem.
I wanna divide 2 numbers and the result to be an integer separated by comma. For example:
$number1=10000000;
$number2=17;
$result=$number1 / $number2;
In this case the result is 588235.29411764....
And I wanna the result to be like this 588,235
thanks
attached mail follows:
yes but if the result is a number like this 34056983 i wanna display this number like this 34,056,983
Please help me with this one
----- Original Message -----
From: Nathan Taylor
To: phpu
Sent: Wednesday, September 10, 2003 2:49 AM
Subject: Re: [PHP] divide
Check out number_format();
www.php.net/number_format
----- Original Message -----
From: phpu
To: php-general
lists.php.net
Sent: Tuesday, September 09, 2003 7:50 PM
Subject: [PHP] divide
Hello,
I'm new in php and i've got allready a problem.
I wanna divide 2 numbers and the result to be an integer separated by comma. For example:
$number1=10000000;
$number2=17;
$result=$number1 / $number2;
In this case the result is 588235.29411764....
And I wanna the result to be like this 588,235
thanks
attached mail follows:
Sorry
I've got it.
Thanks a lot
----- Original Message -----
From: Nathan Taylor
To: phpu
Sent: Wednesday, September 10, 2003 2:59 AM
Subject: Re: [PHP] divide
Check out number_format() like I said.
----- Original Message -----
From: phpu
To: Nathan Taylor
Cc: php-general
lists.php.net
Sent: Tuesday, September 09, 2003 8:04 PM
Subject: Re: [PHP] divide
yes but if the result is a number like this 34056983 i wanna display this number like this 34,056,983
Please help me with this one
----- Original Message -----
From: Nathan Taylor
To: phpu
Sent: Wednesday, September 10, 2003 2:49 AM
Subject: Re: [PHP] divide
Check out number_format();
www.php.net/number_format
----- Original Message -----
From: phpu
To: php-general
lists.php.net
Sent: Tuesday, September 09, 2003 7:50 PM
Subject: [PHP] divide
Hello,
I'm new in php and i've got allready a problem.
I wanna divide 2 numbers and the result to be an integer separated by comma. For example:
$number1=10000000;
$number2=17;
$result=$number1 / $number2;
In this case the result is 588235.29411764....
And I wanna the result to be like this 588,235
thanks
attached mail follows:
On Tuesday 09 September 2003 05:04 pm, phpu wrote:
> yes but if the result is a number like this 34056983 i wanna display this
> number like this 34,056,983 Please help me with this one
that's exactly what number_format() does... from the example on
www.php.net/number_format :
<?php
$number = 1234.56;
// english notation (default)
$english_format_number = number_format($number);
// 1,234
// French notation
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56
$number = 1234.5678;
// english notation without thousands seperator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57
?>
that's all there is to it.
attached mail follows:
Hi,
I wonder if anyone has got a fix or explanation for this;
I;ve just just installed php 4.3.3 on a new w2k server and uploaded a well
tested php application to the new site. basically the problem is that the
$HTTP_POST_VARS, $_POST variables are empty, its probably a config problem
somewhere, but as yet I'm unable to track it down.
Thanks in advance for any pointers on fixing this one!!
Cheers
Tom H
attached mail follows:
Is it possible to tell a browser to send form a to URL a and form b to
URL b?
(i.e. post to two different URLS)
Thanks,
-Dan
attached mail follows:
You can have two different forms posted to two different URLs. Not sure
if you can in a single submit post two different forms to two different
URLs except maybe with Javascript.
Cheers,
Rob.
On Tue, 2003-09-09 at 20:11, Dan Anderson wrote:
> Is it possible to tell a browser to send form a to URL a and form b to
> URL b?
>
> (i.e. post to two different URLS)
>
> Thanks,
>
> -Dan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
.---------------------------------------------.
| Worlds of Carnage - http://www.wocmud.org |
:---------------------------------------------:
| Come visit a world of myth and legend where |
| fantastical creatures come to life and the |
| stuff of nightmares grasp for your soul. |
`---------------------------------------------'
attached mail follows:
Hello,
I am using php to explode the lines of a text file (delimited by a
comma), break it into an array, and echo only one of the array elements.
I have accomplished all of this, but it only echos the text for one
line. How do I get php to scan multiple lines? I tried to introduce a
line count, but I can't find any information on how I can create a loop.
An example would be:
For the below text file, I want to echo
dept, 10, 20, 40 ,30
empid, name, job, dept
10,Wilma Tucker, Sales Engineer, 10
43,James Whitmore, Unix SA, 20
50,Tricia Williams, Systems Developer, 40
427, Barry Regar, Administrative Assistant, 30
Thanks!
-T
attached mail follows:
Sweet T wrote:
> Hello,
>
> I am using php to explode the lines of a text file (delimited by a
> comma), break it into an array, and echo only one of the array elements.
> I have accomplished all of this, but it only echos the text for one
> line. How do I get php to scan multiple lines? I tried to introduce a
> line count, but I can't find any information on how I can create a loop.
>
> An example would be:
Here is an example of how to loop through a array:
$array = file('data.txt');
foreach($array as $value) {
list($id, $name, $job, $dept) = preg_split('/,/', $value);
echo $dept;
}
How is your array setup?
>
> For the below text file, I want to echo
>
> dept, 10, 20, 40 ,30
>
> empid, name, job, dept
> 10,Wilma Tucker, Sales Engineer, 10
> 43,James Whitmore, Unix SA, 20
> 50,Tricia Williams, Systems Developer, 40
> 427, Barry Regar, Administrative Assistant, 30
>
>
> Thanks!
>
> -T
attached mail follows:
Take a look at Turck MMCache and Zend Encoder, both will require your
user to install a free Loader. Turck MMCache is free, Zend Encoder is
not, either will make your applications run faster.
You should workout good licensing deals with your clients because with
enough motivation and time they will reverse engineer an encoded
script. The PHP Obfuscator was intresting but you need to test your
application again after you use it because of the changes it makes to
the code.
Most people recommend good legal licensing and a good relationship, if
that isn't possible I'd use MMCache or Zend Encoder and accept someone
may reverse engineer it at some point, either of these programs are
better than something that obscures the code because the store the
optimized bytecode which will accelerate the program where an encrypted
source file will slow you down, an obscured one shouldn't slow you down
much if at all but then there is the testing thing :).
Jason
Ivo Fokkema wrote:
>Hi,
>
>I've actually been looking for this kind of things for a while as well.
>However, I would not want my client to install something to uncode the
>scripts (probably causing the scripts to be unencoded easier). I found
>these:
>
>PHP OBFUSCATOR
>http://richard.fairthorne.is-a-geek.com/utils_obfuscate.php
>
>Phrozen
>http://sourceforge.net/projects/phrozen/
>
>POBS
>http://pobs.mywalhalla.net/
>
>Anyone have any recommendations or experience with any?
>
>--
>Ivo
>
>
>"Evan Nemerson" <evan
coeus-group.com> wrote in message
>news:200309062144.55392.evan
coeus-group.com...
>
>
>>Take a look at Turck MMCache (free) and Zend Encoder (not).
>>
>>http://www.turcksoft.com/en/e_mmc.htm
>>http://www.zend.com/store/products/zend-encoder.php
>>
>>
>>
>>On Saturday 06 September 2003 01:59 pm, Charles Kline wrote:
>>
>>
>>>What methods are available (ups and downs) for encrypting and
>>>serializing php applications for sale?
>>>
>>>Thanks,
>>>Charles
>>>
>>>
>
>
>
attached mail follows:
* Thus wrote micro brew (microbrewclub
yahoo.com):
> Hi everyone,
>
> I've been experimenting with sessions. I can make
> them work just fine in a normal PHP page. But when I
> create a class and try to define a session variable
> within a method in the class it won't work. I've
> tried setting the session variable directly
> ($_SESSION['name']='somevalue') but that didn't work.
> The normal way of setting it -
> session_start();
> session_register('name');
> $name='somevalue';
You might want to read
http://php.net/session
You are most likley running into a register_globals issue.
A couple things to note:
. You must not mix $_SESSION[] access with session_register()
anywhere in your script.
. When you issue session_register('name') inside your class it is
declaring the global var $name as a session var, not the $name in
your script.
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
attached mail follows:
Is the PHP constant SID always defined? I have found conflicting answer
in the documentation. One page of the docs says it is always defined
while another says it is defined only if the right cookie hasn't been
passed to the server.
Also how can I check if the SID is set or not?
I have tried the following but get an error:
<?php
if (isset(SID)) {}
?>
Parse error: parse error, expecting `T_VARIABLE' or `'$''
Thanks,
Jean-Christian Imbeault
attached mail follows:
* Thus wrote Donald Tyler (chekote69
hotmail.com):
>
> The script seems to run fine the first time I run it, but with subsequent
> runs (To see if it incorrectly creates duplicates of records etc), after a
> couple of minutes the script ends with an error message saying "Lost
> connection to MySQL server during query".
This is a good sign that mysql is crashing for some reason, check
your mysql logs and seek the mysql archives.
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
attached mail follows:
* Thus wrote zavaboy (zavaboy
hotmail.com):
> How do I set execution time for a for() loop?
> Like I have a loop stop once it finds 3 things, but what happens when there
> are only 2 things? It keeps looking for 30 seconds then shows this error:
> Fatal error: Maximum execution time of 30 seconds exceeded in...
>
> How can I set it to 3 seconds without a error?
What you explained seems that you're doing something wrong... can
you provide a small example of what you want to get done?
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
attached mail follows:
anyone managed to get gforge working with mysql at all ? sorry if this might
be off topic but i found the link off this list, let me know thanks.
attached mail follows:
* Thus wrote CF High (noah
newminddesign.com):
> Hey all.
>
> Another simple, yet baffling for me, question:
>
> I have a comma delimited list of numbers; e.g. $num_list = "1,2,3,4"
>
> I split the number list to array -- $num_list_array = split("," $num_list)
>
> I then count the number of elements -- $count = count($num_list_array);
>
> I do not get 4 for $count, rather 1!
>
> I can't stand coming up with cludgy workarounds just to count the number of
> elements in a numerical list.....
So you just want to count how many digits their are?
$num_list = "1,2,3,4";
$count = substr_count($num_list, ",") + 1;
http://php.net/substr_count
No sense of all the extra work in putting it into an array.
HTH,
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]