Jump to content

Recommended Posts

He wants the values off this done

 

<input value="Ny" name="Country[Ny][]" />

<textarea name="Country[Ny][0]"></textarea>

 

but it to hard to do what he wants like that

 

some one show me a an saw then

 

ive never in my life seen a array of Country[0] turned into another array then merged never.

 

THIS CODE DOES NOT WORK THE WAY YOU WANT IT .....

 

SEE YOUR SELF.......

<form method="POST">
<input type="text" name="Country[Ny][]"></textarea>
<textarea name="Country[Ny][0]"></textarea>
<input type="submit" /></form>

<?php

$Country = $_POST['Country'];

$ry=($Country[Ny][0]);

$p=array($ry);

foreach($p as $res){

$r = nl2br($res);

   $b=explode('<br />',ltrim($r));

$result=array_merge($b,$Country);

print "<PRE>"; print_r($result); print "</PRE>";

}


?>

 

as you can seethe result's are wrong what you want.

Array
(
    [0] => JOHN
    [1] => 
JOHN
    [2] => 
JOHN
    [Ny] => Array
        (
            [0] => JOHN
JOHN
JOHN
        )

)

 

He wants the values off this done

 

<input value="Ny" name="Country[Ny][]" />

<textarea name="Country[Ny][0]"></textarea>

 

but it to hard to do what he wants like that

 

some one show me a an saw then

 

ive never in my life seen a array of Country[0] turned into another array then merged never.

 

 

Thanks for your help, I appreciate it.

 

I Will have an answer soon I think, And il post it, Ive easily spent over 5 hours on this shit, Im not giving up now

 

THIS CODE DOES NOT WORK THE WAY YOU WANT IT .....

 

SEE YOUR SELF.......

<form method="POST">
<input type="text" name="Country[Ny][]"></textarea>
<textarea name="Country[Ny][0]"></textarea>
<input type="submit" /></form>

<?php

$Country = $_POST['Country'];

$ry=($Country[Ny][0]);

$p=array($ry);

foreach($p as $res){

$r = nl2br($res);

   $b=explode('<br />',ltrim($r));

$result=array_merge($b,$Country);

print "<PRE>"; print_r($result); print "</PRE>";

}


?>

 

I will try to mess with this if my attempt doesnt work, I think I nearly have it, Thx again

FUCK YEHHHH!!!!!!!!!!!

I FINALLY DID IT. 8) 8) 8) 8)

 

<form method="POST">
<input value="Ny" name="Country[Ny][]" />
<textarea name="Country[Ny][0]"></textarea>
<input value="Ca" name="Country[Ca][]" />
<textarea name="Country[Ca][0]"></textarea>
<input type="submit" /></form>

<?php
$Country = $_POST['Country'];

	print "<PRE>"; print_r($Country); print "</PRE>";

foreach($Country as $CountryId)
{

        while($CountryId = current($Country))
	{
		$New = implode("\n",$CountryId);
		$New = explode("\n",$New);

			foreach($New as $Key)
			{
				unset($Country[key($Country)][0]);
				array_push($Country[key($Country)],$Key);
			}

	next($Country);
	}


}

	print "<PRE>"; print_r($Country); print "</PRE>";

?>

 

OUTPUT

Array
(
    [Ny] => Array
        (
            [1] => FUCK
            [2] => YES
            [3] => I
        )

    [Ca] => Array
        (
            [1] => THINK
            [2] => I
            [3] => DID
            [4] => IT
        )

)

 

I get this theo.

Array
(
    [Ny] => Array
        (
            [0] => john
john
john
        )

    [Ca] => Array
        (
            [0] => john
john
john
        )

)

Array
(
    [Ny] => Array
        (
            [1] => john
            [2] => john
            [3] => john
        )

    [Ca] => Array
        (
            [1] => john
            [2] => john
            [3] => john
        )

)

Was this the order you done.

 

Someone cut it more down so i understand it more cheers.

<form method="POST">
<input value="Ny" name="Country[Ny][]" />
<textarea name="Country[Ny][0]"></textarea>
<input value="Ca" name="Country[Ca][]" />
<textarea name="Country[Ca][0]"></textarea>
<input type="submit" /></form>

<?php

// posted the varable country.
$Country = $_POST['Country'];


// loop the country as countryid
   foreach($Country as $CountryId)
   {
      // while loop countryid via the current value
        while($CountryId = current($Country))
      {
      	
      	//implode the cuntryid 
         $New = implode("\n",$CountryId);
         
         // explode countryid
         $New = explode("\n",$New);
         
         //foreach new s key
            foreach($New as $Key)
            {
            	//unset country as key 0 
               unset($Country[key($Country)][0]);
               
               //ush off the las element of country
               array_push($Country[key($Country)],$Key);
            }
            
            // move to next pointer.
      next($Country);
      }
      

   }

   //print the results.
      print "<PRE>"; print_r($Country); print "</PRE>";

?>

well done, but i want a full explanation of your code now lol.

 

tell us what you done it all good.

 

step by step explain every function looks good.

 

it blown my mind and a fuse...

 

 

 

hahaha, I think already I am confused by it, Their is too many loops to track for me, This is the first time I used multidimensional array

 

But Basically what is happening is

 

foreach($Country as $CountryId)
{

 

INSIDE COUNTRY ARRAY (NY AND CA)

		
        while($CountryId = current($Country))
	{

		$New = implode("\n",$CountryId);
		$New = explode("\n",$New);

 

WHILE WE ARE INSIDE NY ARRAY, CONVERT THE ARRAY TO A STRING, THEN CONVERT BACK TO ARRAY

 

			foreach($New as $Key)
			{
				unset($Country[key($Country)][0]);
				array_push($Country[key($Country)],$Key);
			}

 

WHILST WE ARE IN NY, WE UNSET THE [0], ([0] = the value with no line break)

FOR EACH KEY INSIDE NY Array, ADD TO THE CURRENT SELECTED ARRAY(WHICH IS NY)


	next($Country);
	}

NOW WE ARE BACK INTO THE MAIN ARRAY LOOP, WE HAVE ADDED ALL KEYS AND VALUES IN THE NY ARRAY TO NY, SO WE GO NEXT, INTO THE CA ARRAY, AND THEN THE LOOP GOES THROUGH IT ALL AGAIN.

}

 

Sorry for the caps, Hope you understand it now and can maybe use this in future.

Well i ve never seen a new php programmer get it write first time, well done,

ill have to investigate your code syntax very good.

 

I need to learn lol.

 

Thanks haha, But I really didnt get it right first time, I have been trying for many hours now

First I gave up a few days ago and made all seperate variables, But then yesterday I wanted to try again.

Then today I spent around 4-5 hours of editing and remaking the code etc.

 

I tried over 15 array fucntions over and over again, haha, Some I didnt even know before.

If I didnt get it eventually, I would of broke my PC I think.

 

Btw, I noticed you are from London, are you employed as a php programmer? php Jobs are hard to get in london, I live there too.

No i do programming from home no boss lol,

 

But to be honest the better you are people hire you throw the net.

 

but programming is hard.

 

html

xhtml

css

javascript/ajax

seo

php

mysql

 

that the beginning

 

then advance php meaning OOP

 

then the dreaded seo

 

then we look at a book that says 24hours ye wright..

 

No i do programming from home no boss lol,

 

But to be honest the better you are people hire you throw the net.

 

but programming is hard.

 

html

xhtml

css

javascript/ajax

seo

php

mysql

 

that the beginning

 

then advance php meaning OOP

 

then the dreaded seo

 

then we look at a book that says 24hours ye wright..

 

 

Haha, Yeh the 24 hour book is funny, Its possible to read all in 24 hour, But then wen u wake up the next day, Its all forgotten.

 

I only know

 

Html

Css

Php(intermediate)

SEO

 

Im just starting to learn javascript, can you recommend some good books?

Thanks

good tutorials.

 

http://www.freewebmasterhelp.com/tutorials/javascript

 

http://www.w3schools.com/JS/default.asp

 

All i no sorry.

 

Get all my books and cd's from ebay or amazon sorry.

 

there so many ill be here all day lol.

 

best php book big hard book

php black book

 

beginning php 5

 

have a look on amazon sorry.

 

Dont recommend books it changes so quickly just use php.net

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.