Friday, 3 February 2023

Create duplicate pages with different name .

 $postidd = get_post(2457); 

$pagecontent = apply_filters('the_content', $postidd->post_content); 


  /*$post_details = array(

  'post_title'    => 'manjeet page',

  'post_content'  => $pagecontent,

  'post_status'   => 'publish',

  'post_author'   => 1,

  'post_type' => 'page'

   );

   wp_insert_post( $post_details );*/


function csv_to_array($filename='', $delimiter=',')

{

    if(!file_exists($filename) || !is_readable($filename))

        return FALSE;


    $header = NULL;

    $data = array();

    if (($handle = fopen($filename, 'r')) !== FALSE)

    {

        while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)

        {

            if(!$header)

                $header = $row;

            else

                $data[] = array_combine($header, $row);

        }

        fclose($handle);

    }

    return $data;

}


$csvdata = csv_to_array('../city.csv');

foreach($csvdata as $csvrow){

echo '<pre>';

print_r($csvrow['city']);

echo '</pre>';

}

No comments:

Post a Comment