Jump to content

Recommended Posts

if you're wanting to just straight replace the array with something completely new, without preserving anything, simply assign your new array to the old array. Example:

 

<?php

$x = array (1,2,3);
$y = array (4,5,6);

print_r($x); // old array
echo "<br/>";
$x = $y; // assign new array
print_r($x); // new array

?>

 

Link to comment
https://forums.phpfreaks.com/topic/113328-array-replacement/#findComment-582261
Share on other sites

Here is the part of code for the array

 

$im = imagecreatefromjpeg('images/tree.jpg');
$matrix = array(   array(2,2,-2),
                            array(2,1,-1),
                            array(2,-2,-2) );
makeFilter($im, $matrix);

 

 

It was listed in 3 parts b/c that is the way a 3x3 matrix list variables. So what I want to do is from an input form, if i choose say "sepia" for a filter, I wantthe code for a sepia filter to be put in the array and the script run. When done it would display the sepia filter on the original.

 

 

Your thoughts appreciated

 

 

JIM

 

 

Link to comment
https://forums.phpfreaks.com/topic/113328-array-replacement/#findComment-582337
Share on other sites

Something like

<?php

if(isset($_POST['submit']))
{
    switch($_POST['filter'])
    {
        case 'sepia':
            $matrix = array( array(2,  2, -2),
                             array(2,  1, -1),
                             array(2, -2, -2) );
        break;

        case 'filter2':
            $matrix = array( array for fiter2 );
        break;

        case 'filter3':
            $matrix = array( array for fiter3 );
        break;
    }

    $im = imagecreatefromjpeg('images/tree.jpg');

    makeFilter($im, $matrix);
}

?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Filter:<br /><input type="radio" name="filter" value="sepia"> Sepia<br />
<input type="radio" name="filter" value="filter2"> Filter2<br />
<input type="radio" name="filter" value="filter3"> Filter3<br />
<input type="submit" name="submit" value="Apply Filter">
</form>

Link to comment
https://forums.phpfreaks.com/topic/113328-array-replacement/#findComment-582432
Share on other sites

Wildteen88,

 

thanks for the great use of the switch. Take a look at this and see if it can be added. I was using it in my original script here

 

if ($input == 1)  [b]{
header("location: rockets.php");
}[/b]

else if ($input == 2)  {
header ("Location: loops.php");
}
else if ($input == 3)  {
header ("Location: 2kernel2.php");
}
[\code]


I started merging the new code and tried this

[code]

  switch($_POST['filter'])
    {

	[b]case   'rocket': { header("location: rockets.php"); }[/b]

	break;

        case 'sepia':
            $matrix = array( array(2, 2, -2),
                             array(2, 1, -1),
                             array(2, -2, -2) );
        break;


Here is the line from the input form

[code]<input type="radio" name="filter" value="rocket">Rockets<br />

 

but it is not connecting to the page.

 

 

 

Thanks

 

 

JIM

[/code][/code]

Link to comment
https://forums.phpfreaks.com/topic/113328-array-replacement/#findComment-582514
Share on other sites

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.