php problem

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
jevin94
New php-forum User
New php-forum User
Posts: 8
Joined: Fri Mar 29, 2013 10:02 am
Contact:

Tue Apr 09, 2013 6:02 am

Array ( [0] => hello every one this is my ne [1] => w post )

this is one of the output of print_r(str_split($f)))

so how can i remove Array "( [0] =>" and "[1] =>" and all this type of words...

johnj
php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Tue Apr 09, 2013 8:30 pm

Please read about array_pop() from the php manual
http://php.net/manual/en/function.array-pop.php

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Tue Apr 09, 2013 10:31 pm

alternatively you could do it like:

Code: Select all

$variable = array('this is some arbitar','y text for an',' example.');
$output = '';
foreach ($variable as $fragment){
$output.=$fragment;
}
echo $output;
 

jevin94
New php-forum User
New php-forum User
Posts: 8
Joined: Fri Mar 29, 2013 10:02 am
Contact:

Fri Apr 12, 2013 8:51 am

johnj wrote:Please read about array_pop() from the php manual
http://php.net/manual/en/function.array-pop.php

I dont want to remove the element of the array, i want to remove just text "Array" as mentioned in my problem.

jevin94
New php-forum User
New php-forum User
Posts: 8
Joined: Fri Mar 29, 2013 10:02 am
Contact:

Fri Apr 12, 2013 8:53 am

seandisanti wrote:alternatively you could do it like:

Code: Select all

$variable = array('this is some arbitar','y text for an',' example.');
$output = '';
foreach ($variable as $fragment){
$output.=$fragment;
}
echo $output;
What is the value of $fragment?

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Fri Apr 12, 2013 11:37 am

It depends on the iteration. on each time through the loop, $fragment contains the value from a different index in the array

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests