Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Extra Item In My Array


Why is my code.

$urlarray = explode("/", "/about/new/index.php");
print_r($urlarray);

returning this

Array ( [0] => [1] => about [2] => new [3] => index.php ).

Perhaps I am being dense but why do I have an extra empty value at the beginning of the array. Is there any way I can make it return the ones I want (ie only those containing an actual value) or do I simply have to work around this.




View Complete Forum Thread with Replies

Related Forum Messages:
Write A Conditional Statement To See If The Current Item In An Array Is The Last Item.
This seems like it would be so simple, but I haven't been able to solve it. I want to write a conditional statement to see if the current item in an array is the last item. I tried

if (count($array) == (current($array))

but that didn't work. count($array) will give me the number of items in the array. What do I use for the current position in the array.

View Replies !
Array_unique - How-to Get First Item Value In Repeated Array Item
I would like to know how-to get the first value of repeated items too in an array using something like array_unique. Code:

View Replies !
Extra 1 End Of Array
I decided to print out my array (print_r) and see a 1 at the end or array PHP Code:

Array ( [16] => 16 [19] => 19 [29] => 29 ) 1.

View Replies !
Array Explode Problem Result In A 6 Item Array
I have the following:

$BB_Basket = "basket=¦APL6007,2.00¦AVX8900,1.00¦ARCAV500,1.00";
$basket_containers = explode('¦', $BB_Basket);
unset($basket_containers[0]);
print_r($basket_containers);

This results in

Array ( [1] => APL6007,2.00 [2] => AVX8900,1.00 [3] => ARCAV500,1.00 )

Now when I try to explode further with

$basket_items = explode(',', $basket_containers);
print_r($basket_items);

This results in

Array ( [0] => Array )

This should result in a 6 item array. Any ideas what I'm doing wrong?

View Replies !
Extra Values In Global Array?
I am trying to pass a few arrays to one of the functions w/in a class I've written, and it's doing something very strange. Here's the block of my code where I define my arrays as global: Code:

View Replies !
An Extra Last Empty Field In An 'mysql_fetch_array' Result Array?
I seem to get an extra empty field in every 'mysql_fetch_array' command I issue. For example:

I have a simple table 'tblName':

ID Name
1 Jane
2 Joe
2 Doe

The following code:

$oCursor = mysql_query("SELECT ID from tblName WHERE Name='Jane'");
if (!$oCursor)
{
$bGo = false;
}
else
{
$aRow = mysql_fetch_array($oCursor);
}

results in:

count($aRow) = 2;

$aRow[0] = 1;
$aRow[1] = ''

Am I missing something, doing something wrong, a wrong PHP setting?

View Replies !
Item In Array
I have an array, set up like this:

$this->navigation_array['Home'] = array('text' => 'Home', 'act' => 'Home', 'redirect' => 'No', 'active' => 'Home', 'link' => 'index.php?act=home', 'default' => 'Info');
$this->navigation_array['Forums'] = array('text' => 'Forums', 'act' => 'Forums', 'redirect' => 'No', 'active' => 'Forums', 'link' => 'index.php?act=forums', 'default' => 'Info');
$this->navigation_array['Users'] = array('text' => 'Users', 'act' => 'Users', 'redirect' => 'No', 'active' => 'Users', 'link' => 'index.php?act=users');
$this->navigation_array['Config'] = array('text' => 'Configuration', 'act' => 'Config', 'redirect' => 'No', 'active' => 'Config', 'link' => 'index.php?act=config');

I want to find the first item inserted into the array, namely "Home". What is the fastest way to just call the first entry? You cant use $this->navigation_array[0] in this case because the keys are text not numbers.

View Replies !
Deleting An Array Item
I have a standard array:
$foo = array(
0 => 'abc'
1 => 'def'
2 => 'ghi');

and I have a variable, $bar, which equals 'def' ... and I want to check
my array to see if the value of $bar exists in the array, and if it
does, delete it from the array.

if (in_array($bar, $foo)) {
// what goes here???
}

I've done this before, but for the life of me, I'm drawing a blank now.
Help a bruthah out?

View Replies !
Random Item Of An Array
What is the best way of picking out a random item of an array, regarding speed and CPU-usage ? I need a super fast way of picking out an ID from my MySQL db.

View Replies !
Delete Item From Array
How do I search for an item within an array, then delete it?

View Replies !
Remove An Item From And Array Entirely
How do you remove an item from an array...

View Replies !
Remove Item From Array
I'm having some trouble understanding how to remove items from an array. The array is created like this: Code:

View Replies !
Modify Array Item
I'm building a shopping cart and need to add the function so if an item is selected twice, the 'quantity' counter increments. I can't get the syntax right for modifying the array value. I have this:

foreach ($_SESSION['basket'] as $key => $row)
{
if ( $row['gnsz']==$gnsz)
{
$newqty=$row['qty'] ;
$newqty++;
$row['qty']= $newqty;
}
}

it picks up the first qty value but I can't seem to modify it in the array. I'm making a dumb mistake somewhere .

View Replies !
Put The Itemid Of An Item Into An Array.
$count = 1;
foreach($trade as $val) {
$val = checkinput($val);
$sel=mysql_query("SELECT * FROM `inventory` WHERE `ID` = '$val' AND `userid` = '$userid2'") or die(mysql_error());
$n=mysql_num_rows($sel);
if($n == 0) {
$input = "You do not own this item.";
error($input);
}
$g=mysql_fetch_array($sel);
$itemid = $g['itemid'];
$itemid[$count] = $itemid;
$count++;

}

Basically, my script is trying to put the itemid of an item into an array. The problem i'm getting is that, it's not saving the values in the array. For example, if i have 3 items and it puts them into the array, it will only save the 3rd item in the array $itemid[3] and 1 and 2 will be blank.

View Replies !
Current Item From An Array
i have an include file with many arrays that look like this: Code:

$event[] = array ('stuff' => 'bla');
$times[] = mktime(0,0,0,6,9,2007);

as of right now, I am using asort to sort all of these by date and display them as a list.

View Replies !
Find Item In Array
I have the following array

$array = array('k1' => 'v1','k2' => 'v2','k3' => 'v3','k4' => 'v4');

how do i select the value that is provided BEFORE the key i provide

ex:
$mykey = "k2";
$array = array('k1' => 'v1','k2' => 'v2','k3' => 'v3','k4' => 'v4');
$value = somefunctions(); // gives the value v1

ex:
$mykey = "k4";
$array = array('k1' => 'v1','k2' => 'v2','k3' => 'v3','k4' => 'v4');
$value = somefunctions(); // gives the value v3.

View Replies !
How To Remove An Item From An Array
Been looking around on how to remove an item from an array, i need the item totally removing, without a gab in the array, as i will be using the implode fuction afterwards.

View Replies !
Item In A Multidimensional Array
I have a multidimensional array (I think). It is an array that has arrays inside it. The inside arrays all have the same structure, (qty, product, color, size). How do I count how many items are 'White' * qty? I looked into the php manual and found array_count_values but others say it doesn't work with MD arrays.:confused:

array(
[0] array([0]qty, [1]product, [2] color, [3] size)
[1] array([0]qty, [1]product, [2] color, [3] size)
[2] array([0]qty, [1]product, [2] color, [3] size)
[3] array([0]qty, [1]product, [2] color, [3] size)
[4] array([0]qty, [1]product, [2] color, [3] size)
[5] array([0]qty, [1]product, [2] color, [3] size)
[6] array([0]qty, [1]product, [2] color, [3] size)
...)

View Replies !
Delete An Item From An Index Array?
How can I delete an Item from an index array in php4?

View Replies !
Shopping Cart Item Array
Trying to build a small simple shopping cart and I am having difficulty getting the solution. The cart is displaying each product, but it is overwriting the values. So if I have added 10 products, it shows ten items, but each item has the values of the last product I added.

I think that this may be due to me trying to use a key to store both an array and string at once, but Iam not sure. I have looked at other examples but due to different methods, syntax is throwing me off. Code:

View Replies !
Remove A Single Item From An Array
I have gathered an array of ID's. I need to go throught the array and find a specific ID and remove it from the array. Because we want to keep that ID. Any suggestion of how to do that.

View Replies !
Preg_split First Item In Array Is Blank
could someone please explain to my why using the code below generates a blank item in $array[0] please. The 'x' from xbox360 is in $array[1]?

View Replies !
Remove Item From Session Array
i have a simple script that adds an item id to a session Code:

View Replies !
Select One Row Of An Array Where Item Number Is ..?
When I call the Ebays XML API I get an array or something similar back (see the code sample), is it possible to "select item_id where item_id = 123123" or something similar as in MySQL? If, How can I do that? Also, I need to attach a PHP variables to the row I selected as for example $starttime, $endtime and so on.

Here is the code sample (the end of the scritpt);

PHP Code: ....

View Replies !
Retrieving Previous Array Item
I have an array. The array key is the id of the item (for example
categories[91], 91 is the ID of the category) all ID are not exactly in
date order, but they're added to the array in date order, how do I find
the previous (in the sense of when it was added) array entry of, for
example category[ྗ']?

View Replies !
Extra Fields Vs Extra Queries
Should I use a join in which I will definitely have 2 out of 4 fields that will never be used. PHP code would use these results to decide which fields to use.

OR

Should I only select the minimum fields and then have another query select the two fields I'm going to need. This would be decided using PHP based on results from the first query.

View Replies !
Arrays : Returning A Reference To An Array Item ??
I am currently storing a set of objects inside an array,

$itemlist = array();
$itemlist[] = new item("myitem");
//...

and I am looking to develop a search function, which returns a
reference to the found item.

function &search_item($itemlist,"myitem") {
//...
}

I am trying to figure out how to obtain a reference to a given item in
an array.
Indeed, foreach() and each() seem to work on copies of the data in the
array.
For example:

$array = array("a","b","c","d");
print_r($array);
foreach($array as $v) $v="xxx";
print_r($array); // $array is unchanged

reset($array) ; while(list(,$v)=each($array)) $v="xxx";
print_r($array); // $array is unchanged, again

View Replies !
Deleting A Single Item From The Middle Of An Array?
I have an array that contain objects, I want to be able to test against the id of that object and remove it from the array. In it's simplest for I want to go from this:

$people = array('Tom', 'Dick', 'Harriet', 'Brenda', 'Jo');

...to this...

$people = array('Tom', 'Dick', 'Brenda', 'Jo');

The fact that the items in the array are objects should not matter right? Plus I've already written my loops and conditionals to check which item i need to remove.

function removeItem ( $item ) {
   $len = count ( $_SESSION['basket_arr'] ) ;
   if ( $len == 1 ) {
      emptyBasket ( ) ;
   } else {
      for ( $i = 0 ; $i < $len ; $i++ ) {
         if ( $item->id == $_SESSION['basket_arr'][$i]->id ) {
            //$_SESSION['basket_arr'][$i] must go
         } } }}


View Replies !
Removing Item From Array Then Overwriting File
I have a bookings.txt file which has a list of dates each on a new line, for example: -

21/06/07
22/06/07
29/06/07
25/12/07
01/01/08

I also have a variable $event_dd_mm_yy which I want to remove from this file if found. Code:

View Replies !
Getting Rid Of Extra ''
I have a PHP script that adds text to a file. Now when I add the text it escapes any ' and ". I know there are functions to remove the , but there is also some legitimate in the text. How do I stop PHP from taking it upon itself to escape the ' and " for me?

View Replies !
Extra Characters
I'm trying to create a csv file to download. The file that is being created has three extraneous characters at the end. I experimented with several different versions of
to make sure it wasn't something there. No matter what combination I use, I still get the 3 extra return characters. Is there something that PHP adds to a file?

Here's the code that creates the variable: PHP code:

View Replies !
Extra Line In Xml
i have this code to insert context into xml the problem is when the context is inserted a extra blank line is inserted..

and if you know about xml you can't have no extra blank line.. this is the code:

View Replies !
Extra Backlashes
I have an issue that when I extract data from mysql table it's including backlashes with quotes. Example if I enter "james" in the table when I extract the data I get "james"

Is there a function to correct this issue? This is a remote server and I don't have access to the PHP.ini file.I am using the code below to enter a value into the table

trim(mysql_real_escape_string($value))

I am using the follow code to retrieve the data

<?php echo $row['value_name']; ?>

Both codes are incomplete but these are the lines that I think are affecting the output.

View Replies !
Extra Fields As Necessary
Post was moved here: http://www.webmasterworld.com/javascript/3390539.htm

View Replies !
Extra In The Mail Message
i use php to process mail form. Mail was sent successfully. but in the message isn't that cool? becomes isn't that cool? there's an extra slash. is there a way to fix this?
also when we check and validate the user input from the mail form, is it better to do it on the server side or client side? i.e using javascrip or php?

View Replies !
Remove Extra Space
Is there a way to take a string that the user has submitted and check the beginning for any extra spaces, and then remove the extra space up to the first real "character" (letter or number)? I hope that isn't too confusing, just ask if you need me to explain better.

View Replies !
Extra Space Is Added
I used the search option but i couldnt get solution for my problem. When i retrieve value from mysql db and place in a textbox an extra space is attached at the end.

View Replies !
Remove An Extra Character From Php
i'm currently working on rss feeder. In that i'm parsing xml values to php. but along with the xml values i'm getting some unwanted characters to like some html tags(i.e. <i> </i>,<br> <br> etc...).

so in php it is showing as below

for eg. : legal+team.+%3Cbr%3E%3Cbr%

in the above example legal+team. are the xml values getting from the rss along with an extra chracter %3Cbr%3E%3Cbr%.

so how should i remove those unwanted extra characters in php.

anybody is having any idea?

View Replies !
Extra Space From If Statements
For some odd reason, the more fields that I enter information for (that are NOT required) adds more empty, white space to the top of the php page.

It has something to do with all my if statements in the php. I viewed the source and there are not any extra breaks or anything to place the information something like 10 lines down. Code:

View Replies !
Extra Column In MYSQL
What information goes into Extra? Except auto_increment.

View Replies !
Strip Extra Breaks
I noticed taht i have some output with extra spaces in the output. I looked at the source and see that there are some breaks that I'd like to remove. I've tried:
PHP Code:

$str = preg_replace('</P><br />', '', $str);

Seems like something is wrong as I loose the output. Do I need to escape something? Coffee, where's my coffee?

View Replies !
Extra Comma In Update Sql
I am using a foreach loop to create the statement. Everything looks good with the sql statement when I echo it; but the last update field has a comma , that is not needed. How to I account for the last $key => $value set in the array that match my criteria and not have a comma?

        $sql = "UPDATE facform SET ";

foreach ($_POST as $key => $value) {

if($key != 'submit' && $value != ''){
$sql .= "$key = $value, ";
}
}

$sql .= "WHERE id = $id";

View Replies !
Why The Extra Line Breaks
I'm trying to get something that reads out of a database and then has a drop down menu for each piece it gets out of the data base i.e.

car1 color option box
car2 color option box
car3 color option box
car4 color option box
car5 color option box

where color option box is a drop down menu with different choices, with the eventual goal of updating the database with changes made.

Right now I can't figure out why the drop boxes appear one line below the leader for the line, I also can't figure out why the extra drop box is being generated at the end. Code:

View Replies !
Remove Extra Caracter
I have problem with extra caracter at the end in my output. We first do some stuff with mysql; Code:

while ($mysql_array = $db->fetch_array()) {

$rednibroj = $mysql_array['rednibroj'];
$nazivbanera = $mysql_array['nazivbanera'];
$image .= "$mysql_array[slikabanera]";
$urlbanera .= "$mysql_array[urlbanera],";
$image = $image.','
}

Code:

print $image.''

The result of this is like this :

var imgList = new Array("ban.jpg,banner.jpg,").

View Replies !
PHP Commands Vs. Extra MySQL Rows
What's better, storing extra information on something in a mySQL database, or using code to go through the database to find the information? For example, for the forum I am writing, I'm not sure whether I should store the last post of the user in thier row, or I should use the code to search through all the posts and find the last one by the user.
Which do you think is better and why?

View Replies !
Add An Extra Space After Period In A String
I want to be able to add an extra space in each instance
after a period in a string. I am already stripping out extra
whitespace throughout, so to start I have a nice flat string to work
with. I am struggling getting the syntax right and keep getting funny
results. What is the simplest way to accomplish this?

View Replies !
Nl2br( ) Function Adds Extra Br
I recently installed phpDev4 (apache, php and MySQL) for local staging of web sites before uploading to my "online" web account. I have a script that takes a field from a database and converts new line characters to <br /> using nl2br( ). I downloaded a csv table from online MySQL and loaded the csv into my local MySQL for testing purposes.

When I run this script from my online account, everything is fine. However when I run this script locally php generates an extra <br />with double quotes and a number at the end of the field data. online html ex. this is a paragraph whose <br /> newline characters are converted to the break xhtml tag.

local html ex. this is a paragraph whose <br /> newline characters are converted to the break xhtml tag."<br />6". Why is "<br />6" added on the end? Is there something within php.conf file that I need to change?

View Replies !
PHP Reading Extra File Info...
I am an ameture digital photographer (along with a newbie developer) and
I've an album of my pictures online. I've been building this album to be
just how I want it and I've come to one last feature that I can't figure
out.

How do I read the extra file info from a .jpg image file (or any other file
for that matter)?

Each one of my pictures has 10 or 20 things included in the file like the
Camera model, f-stop used, etc... and I want to be able to parse that out
and show it on screen.

Is that possible with PHP?

View Replies !
Adding And Extra Clause To Php/pdf File
I'm hoping this is relatively straightforward! I generate pdf invoices from php files and depending on which company they are for they load different logos as in }

if($bookerCompany='CIMINT'){
$logo="printlogo1.jpg";
}else{
$logo="printlogo_iwant.jpg";
}
I now need to seperate these into sterling and non sterling print batches. I have any existing line that differentiates between UK and non UK documents if ($currency!='Sterling'){ this being non sterling and dropping the '!' for sterlings docs. Now I need to combine the booker company with the currency type to make all the right bits load into the doc.

View Replies !
Renaming A File And Add An Extra Bit Of Text To The End
when a user uploads an image file i delete the name of the file and append a random 8 digit number to it (keeping the files original extension)

so : graham23spic.jpg would be 12345678.jpg, i was wanting to add an extra bit of text to the end of the photo kinda like: 12345678.jpg-Users_Photo

but i'm not sure how to do this my rename code is:

View Replies !
Upload And Extra Characters In Word Doc
I have a question that is holding my development up - and it's down to Microsoft!

I am developing a site where users upload documents (using php upload), and the content of the uploaded file is inserted into a mysql database. It all works fine - apart from the hundreds of extra characters added by Microsoft Word, above and below the content.

We do not want to restrict the doc type on upload as there will be many different formats used and we want to make it as easy for the user as possible.

Most solutions I have seen simply say to save the Word file as a .txt file - this is not an option. We MUST be able to upload many different types of Word processing files and strip out the extra characters.

View Replies !
Remove Extra Line Breaks
What is the correct expression to remove any extra line breaks beyond two in a string?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved