For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > April 2005 > Search and delete









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Search and delete
InSeCo

2005-04-18, 8:55 am

Hello,

how can I delete a part from an array?

I want to search in the array to the first 5 characters, after that I want
to delete the value from the array!

## Before
$example = array(
1 => '1001,sastu',
2 => '1003,dudaa',
3 => '1006,s1001fd',
4 => '1008,empdat',
5 => "1010,limaad",
);

##after searching for "1006," the record must be deleted!
$example = array(
1 => '1001,sastu',
2 => '1003,dudaa',
4 => '1008,empdat',
5 => "1010,limaad",
);

Thnx,
InseCo







Sebestyén Dénes

2005-04-18, 8:55 am

Hi!

I suggest that your script run over the array, and use fnmatch (or preg)
to know whether it's the one what it wants to find.

Best regards
Titan

InSeCo wrote:
> Hello,
>
> how can I delete a part from an array?
>
> I want to search in the array to the first 5 characters, after that I want
> to delete the value from the array!
>
> ## Before
> $example = array(
> 1 => '1001,sastu',
> 2 => '1003,dudaa',
> 3 => '1006,s1001fd',
> 4 => '1008,empdat',
> 5 => "1010,limaad",
> );
>
> ##after searching for "1006," the record must be deleted!
> $example = array(
> 1 => '1001,sastu',
> 2 => '1003,dudaa',
> 4 => '1008,empdat',
> 5 => "1010,limaad",
> );
>
> Thnx,
> InseCo
>
>
>
>
>
>
>

Sebestyén Dénes

2005-04-20, 8:55 am

Hi!

I suggest that your script run over the array, and use fnmatch (or preg)
to know whether it's the one what it wants to find.

Best regards
Titan

InSeCo wrote:
> Hello,
>
> how can I delete a part from an array?
>
> I want to search in the array to the first 5 characters, after that I want
> to delete the value from the array!
>
> ## Before
> $example = array(
> 1 => '1001,sastu',
> 2 => '1003,dudaa',
> 3 => '1006,s1001fd',
> 4 => '1008,empdat',
> 5 => "1010,limaad",
> );
>
> ##after searching for "1006," the record must be deleted!
> $example = array(
> 1 => '1001,sastu',
> 2 => '1003,dudaa',
> 4 => '1008,empdat',
> 5 => "1010,limaad",
> );
>
> Thnx,
> InseCo
>
>
>
>
>
>
>

Sebestyén Dénes

2005-04-25, 3:56 pm

Hi!

I suggest that your script run over the array, and use fnmatch (or preg)
to know whether it's the one what it wants to find.

Best regards
Titan

InSeCo wrote:
> Hello,
>
> how can I delete a part from an array?
>
> I want to search in the array to the first 5 characters, after that I want
> to delete the value from the array!
>
> ## Before
> $example = array(
> 1 => '1001,sastu',
> 2 => '1003,dudaa',
> 3 => '1006,s1001fd',
> 4 => '1008,empdat',
> 5 => "1010,limaad",
> );
>
> ##after searching for "1006," the record must be deleted!
> $example = array(
> 1 => '1001,sastu',
> 2 => '1003,dudaa',
> 4 => '1008,empdat',
> 5 => "1010,limaad",
> );
>
> Thnx,
> InseCo
>
>
>
>
>
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com