Hi,
thanks for your post, and sorry for the trouble.
You could use the TablePress PHP functions from the “table model” here, like
$table_id = '123';
$table = TablePress::model_table->load( $table_id, true, false );
if ( 'some-text' === $table[0][0] ) {
// do something.
}
Regards,
Tobias
Thanks
There was a $
missing from model_table
and then this returns an array with a 2 dimensional array in one of the primary array elements
so my code is
$table_id = '27';
$table = TablePress::$model_table->load( $table_id, true, false );
foreach($table as $key => $value)
{
if ($key=='data')
{
foreach($value as $key => $value2)
{
foreach($value2 as $key => $value3)
{
if ($key=='0')
{
$l=strlen($title);
$k=substr($value3,0,$l);
if ($title==$k)
{
echo 'title= ',$title,' long_title= ', $value3;
continue;
}
}
}
}
}
}
Hi,
ah, my bad for that typo! Good to hear that this was useful!
You might even be able to shorten all this to
$table_id = '27';
$table = TablePress::$model_table->load( $table_id, true, false );
foreach( $table['data'] as $row ) {
$first_cell_value = $row[0];
$title_length = strlen( $title );
$shortened_cell_value = substr( $first_cell_value, 0, $title_length );
if ( $title === $shortened_cell_value ) {
echo 'title= ', $title, ' long_title= ', $first_cell_value;
break;
}
}
Best wishes,
Tobias
Thanks
You are better at this than I am
Hi,
no problem! Always happy to help!
Best wishes,
Tobias